在Ubuntu20.04下安装MySQL 5.7.41

前几天要在centos 7下运行OBS Studio,结果努力了好几天都运行不了。最后妥协了,决定在Ubuntu下安装。这样系统就要整体移植到Ubuntu,其中就包括了MySQL服务。这里把安装过程记录一下。

1、sudo apt update

更新一下安装源

2、sudo apt install -y mysql-server-5.7

安装过程需要输入两次mysql的root用户的密码

3、mysql -V

查看一下安装的MySQL版本

4、mysql -uroot -p

登录MySQL服务

5、use mysql;

6、update user set host='%', password_expired='N' where host='localhost';

扫描二维码关注公众号,回复: 14967034 查看本文章

设置用户不过期

7、update mysql.user set Host='%' where HOST='localhost' and User='root';

允许从本地和远程链接

8、update user set plugin="mysql_native_password" where user='root';

root用户在使用auth_socket插件 我们让他用mysql_native_password

9、set password=password('您要使用的密码');

重置一下密码

10、FLUSH PRIVILEGES;

加载使修改生效

11、sudo vim /etc/mysql/mysql.conf.d/mysqld.cnf

把bind-address  = 127.0.0.1  注释掉,取消链接IP限制

12、service mysql restart

重启MySQL

下面是在Ubuntu下卸载MySQL的命令:

1、sudo apt-get autoremove --purge mysql-server

2、sudo apt-get --purge remove mysql-common

3、sudo rm -rf /etc/mysql/ /var/lib/mysql

4、dpkg -l | grep ^rc| awk '{print $2}' | sudo xargs dpkg -P

5、sudo apt autoremove

6、sudo apt autoclean

下面是在Ubuntu下对MySQL的操作命令:

1、sudo service mysql start

启动服务

2、sudo service mysql stop

关闭服务

3、sudo service mysql restart

重启服务

猜你喜欢

转载自blog.csdn.net/ziele_008/article/details/130379937