deepin系统安装mysql
系统信息
deepin 15.11 桌面版
64位
apt-get 源 为 阿里云
安装mysql
最好在deepin不安装其他软件的时候安装mysql,防止依赖冲突!
-
使用apt方式直接安装
sudo apt-get install -y mysql-server mysql-client
-
设置密码
sudo mysql -uroot -p
-
分别执行以下命令,注意将密码修改
GRANT ALL PRIVILEGES ON . TO ‘root’@’%’ IDENTIFIED BY ‘这里是你的密码’ ;
flush privileges; -
登录测试
mysql -uroot -p
无法登录
如果已经完成了上述操作,但是无法登录mysql,你需要执行以下命令:
-
mysql身份验证过程已调用“ unix_socket”(可能与数据库到mariadb的部分迁移有关,现已删除)。要使所有内容恢复正常工作,请执行su:
sudo su
-
执行以下
/etc/init.d/mysql stop
mysqld_safe --skip-grant-tables &
mysql -uroot这将完全停止mysql,绕过用户身份验证(无需密码)并使用用户“ root”连接到mysql。
-
在mysql控制台中,使用mysql管理数据库:
use mysql;
-
要将根密码重设为mynewpassword(根据需要更改)
update user set password=PASSWORD(“这里是你的密码”) where User=‘root’;
-
覆盖身份验证方法,删除unix_socket请求(以及所有其他内容),恢复正常且有效的密码
update user set plugin=“mysql_native_password”;
-
退出mysql控制台
quit;
-
停止并启动与mysql有关的所有内容:
/etc/init.d/mysql stop
kill -9 $(pgrep mysql)
/etc/init.d/mysql start -
exit su 模式
-
使用root登录
mysql -u root -p
大小写敏感
-
cd /etc/mysql/ 目录发现以下文件
conf.d debian-start mariadb.conf.d my.cnf.fallback debian.cnf mariadb.cnf my.cnf
-
需要修改
my.cnf
sudo vi my.cnf
-
你可以看到以下内容
# The MariaDB configuration file # # The MariaDB/MySQL tools read configuration files in the following order: # 1. "/etc/mysql/mariadb.cnf" (this file) to set global defaults, # 2. "/etc/mysql/conf.d/*.cnf" to set global options. # 3. "/etc/mysql/mariadb.conf.d/*.cnf" to set MariaDB-only options. # 4. "~/.my.cnf" to set user-specific options. # # If the same option is defined multiple times, the last one will apply. # # One can use all long options that the program supports. # Run program with --help to get a list of available options and with # --print-defaults to see which it would actually understand and use. # # This group is read both both by the client and the server # use it for options that affect everything # [client-server] # Import all .cnf files from configuration directory !includedir /etc/mysql/conf.d/ !includedir /etc/mysql/mariadb.conf.d/
可以详细看看以上注释内容,/etc/mysql/my.cnf 是默认的总体设置,百度一大堆修改mysql大小写敏感之后,都说修改
my.cnf
中[mysqld]
下添加啊lower_case_table_names=1
.但是这个文件中并没有这个[mysqld]
,这很令人蛋疼…我尝试过直接添加lower_case_table_names
,但是很遗憾,并没有啥用.这里就不解释我经历的过程,直接陈述解决方式.- 修改
my.cnf
,在下面直接添加
[mysqld] lower_case_table_names=1
- 然后重启mysql服务
service mysqld start
-
这时候你可以登录mysql,尝试直接使用大写来查询表,如下
mysql -uroot -p use demo; select * from DEMO_TABLE; select * from demo_table;
如果大写报错的话,你可能需要执行
set @lower_case_table_names=1;
然后重试以上操作.
- 修改