Deepin安装mysql5.7
0、前言
今天也是在本机上装上linux系统了,也想体验一下。
刚刚需要安装
1、 Mysql 的安装
sudo apt-get install mysql-server mysql-client
注意:安装的时候记得要换源,Deepin的官方源不支持这种方式来安装
2、设置密码
登录Mysql
mysql -u root
这个时候回直接进去,也就是说没有密码验证的。
然后给root账户设置密码即可
usr mysql;
select host,user,plugin,authentication_string from user;
update user set plugin="mysql_native_password",authentication_string=password('新密码') where user="root";
FLUSH PRIVILEGES;
3、设置编码
登录Mysql之后,输入命令查询当前的编码SHOW VARIABLES LIKE 'char%';
如果不是utf8那么就直接都设置为utf8
在etc/mysql/my.cnf的文件修改它即可
vim /etc/mysql/my.cnf
然后添加
[mysqld]
character-set-server = utf8
重启mysql的服务,然后再次查询就会成功了。
service mysql restart
4、忘记密码
- 检查mysql服务是否正在运行
- 关闭登录验证,修改密码
- 重启mysql服务
检查mysql的服务是否在运行,并且关闭
ps -ef | grep -i mysql
# 关闭服务
service mysql stop
修改密码
在/etc/mysql/my.cnf中添加
[mysqld]
skip-grant-tables
目的是为了过Mysql的登录验证
然后修改密码
use mysql;
update mysql.user set authentication_string=password('新密码') where user='root';
重启服务
service mysql restart

浙公网安备 33010602011771号