ubuntu mysql8_Ubuntu 18.04 安装 mysql 8.0

卸载之前安装的 mysql 5.7

sudo apt-get autoremove --purge mysql-server

sudo apt-get remove mysql-server

sudo apt-get autoremove mysql-server

sudo apt-get remove mysql-common

安装 mysql 8.0

首先需要去 mysql 官网

https://dev.mysql.com/downloads/repo/apt/

下载一个 Ubuntu / Debian (Architecture Independent), DEB Package (mysql-apt-config_0.8.10-1_all.deb) 的安装包

sudo dpkg -i mysql-apt-config_0.8.10-1_all.deb

选择 mysql 8.0,然后退出

sudo apt update

sudo apt install mysql-server

mysql 8.0 的创建账户的语法变更

mysql> CREATE DATABASE mysql8_test;

Query OK, 1 row affected (0.15 sec)

mysql> GRANT ALL PRIVILEGES ON mysql8_test.* TO 'mysql8_test'@'localhost' IDENTIFIED BY 'password';

ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'IDENTIFIED BY 'password'' at line 1

mysql 8.0 里,正确的做法是先创建一个用户

create user 'mysql8_test'@'%' identified by 'password';

再进行授权

grant all privileges on *.* to 'mysql8_test'@'%' with grant option;

一些 mysql 8.0 的奇葩问题

mysql> create user 'mysql8_test'@'%' identified by 'password';

ERROR 1146 (42S02): Table 'mysql.role_edges' doesn't exist

需要升级解决

sudo mysql_upgrade -u root -p

然后,等待更新完成即可

Checking if update is needed.

Checking server version.

Running queries to upgrade MySQL server.

Upgrading system table data.

Checking system database.

mysql.columns_priv OK

mysql.component OK

mysql.db OK

mysql.default_roles OK

mysql.engine_cost OK

mysql.func OK

mysql.general_log OK

mysql.global_grants OK

mysql.gtid_executed OK

mysql.help_category OK

mysql.help_keyword OK

mysql.help_relation OK

mysql.help_topic OK

mysql.innodb_index_stats OK

mysql.innodb_table_stats OK

mysql.ndb_binlog_index OK

mysql.password_history OK

mysql.plugin OK

mysql.procs_priv OK

mysql.proxies_priv OK

mysql.role_edges OK

mysql.server_cost OK

mysql.servers OK

mysql.slave_master_info OK

mysql.slave_relay_log_info OK

mysql.slave_worker_info OK

mysql.slow_log OK

mysql.tables_priv OK

mysql.time_zone OK

mysql.time_zone_leap_second OK

mysql.time_zone_name OK

mysql.time_zone_transition OK

mysql.time_zone_transition_type OK

mysql.user OK

Found outdated sys schema version 1.5.1.

Upgrading the sys schema.

Checking databases.

sys.sys_config OK

Upgrade process completed successfully.

Checking if update is needed.

对于密码强度要求很高

mysql> create user 'mysql8_test'@'%' identified by 'password';

ERROR 1819 (HY000): Your password does not satisfy the current policy requirements

mysql> create user 'mysql8_test'@'%' identified by 'Password123!';

Query OK, 0 rows affected (0.12 sec)

与时俱进

参考

https://blog.csdn.net/iversonx/article/details/80341596


版权声明:本文为weixin_33985453原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。