ubuntu18.04安装mysql8 执行一下操作:
1)sudo apt-get install wget
2)wget https://repo.mysql.com//mysql-apt-config_0.8.10-1_all.deb
3)sudo dpkg -i mysql-apt-config_0.8.10-1_all.deb
<-- Selecting previously unselected package mysql-apt-config.
(Reading database ... 127849 files and directories currently installed.)
Preparing to unpack mysql-apt-config_0.8.10-1_all.deb ...
Unpacking mysql-apt-config (0.8.10-1) ...
Setting up mysql-apt-config (0.8.10-1) ...
Warning: apt-key should not be used in scripts (called from postinst maintainerscript of the package mysql-apt-config)
OK -->
4) 弹出安装对话框:选择MySQL8 -----》OK
5) sudo apt-get update
如果出现一下错误:Err:4 http://repo.mysql.com/apt/ubuntu bionic InRelease
The following signatures were invalid: EXPKEYSIG 8C718D3B5072E1F5 MySQL Release Engineering <mysql-build@oss.oracle.com
解决方法:
1,查看签名列表:apt-key list
2,删除过期的签名;(del 后跟上条指令查到的pub)sudo apt-key del dsa1024
3,重新添加新的签名;sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 8C718D3B5072E1F5
4,重新执行: sudo apt update
6)sudo apt-get install mysql-server
7)当询问root密码时,输入root密码------》再次确认密码
8)select defult authentication plugin ----->选择use Legacy Authentication Method (Retain Mysql5.x Comptibility) -----> enter
9)安装完成systemctl status mysql
10)停止mysql 服务 :sudo service mysql stop
11)启动mysql服务:sudo service mysql restart
12)Navicat远程连接数据库:需要修改root 所对应的Host 为'%'。(不修改只能在local host机器上登陆mysql)
登陆Mysql mysql -uroot -p ------->回车--------->输入密码----------->show databases;(注意分号)----------->use mysql ----------->update user set host = '%' where user = 'root';
---------->select host, user from user;-------->查看修改完成后执行FLUSH PRIVILEGES;---------->完成后可尝试Navicat连接
13)在ubuntu server 18.04上迁移MySQL数据目录(将数据目录迁移至更大的磁盘空间)
(1)停mysql服务
(2)拷贝 /var/lib/mysql/ 到 /data/mysqldata/。为了确保文件权限正确,拷贝时加 -a 参数。
sudo cp -a /var/lib/mysql /data/mysqldata/
(3)修改配置文件 /etc/mysql/mysql.conf.d/mysqld.cnf 中的 datadir 配置项
datadir = /data/mysqldata/ (vi /etc/mysql/mysql.conf.d/mysqld.cnf)
(4)配置AppArmor访问控制规则,文件路径是:/etc/apparmor.d/usr.sbin.mysqld (vi /etc/apparmor.d/usr.sbin.mysqld)
注释掉原数据目录规则
# /var/lib/mysql r,
# /var/lib/mysql/** rwk,
新增
/data/mysqldata/ r,
/data/mysqldata/** rwk,
(5)重启mysql服务,迁移数据目录完成。