网上教程都比旧,也不是第一次安装了,但依然仍是花了比较多的时间,特此记录本次安装过程。因是安装完毕后回忆记录,或有错漏。mysql
第一步:sql
下载 mysql apt 配置文件: https://dev.mysql.com/downloads/repo/apt/ubuntu
第二步:socket
启动 mysql 配置: sudo dpkg -i mysql-apt-config_0.8.16-1_all.deb, 文件名称可能会变化。ui
第三步rest
选择 MySQL Server & Cluster, 回车,继续选择 mysql 8, 回到最开始的页面后,下移选择 "ok"code
第四步server
sudo apt-get update教程
第五步ip
安装mysql: sudo apt-get install mysql-server
第六步
启动mysql: service mysql start
第七步
进入MySQL: sudo mysql -u root -p
无需输入密码,直接回车。
第八步
可选,本人将 mysql 库下 user 表 host, authentication_string 修改成 "%", "123"
use mysql; update user set host='%',authentication_string='123' where user='root'; flush privileges;
修改后查看 user 用户信息:
select user,host,authentication_string,plugin from user where user = 'root' \G; *************************** 2. row *************************** user: root host: % authentication_string: 123 plugin: auth_socket
第九步
修改 /etc/mysql/mysql.conf.d/mysqld.cnf 文件, 在 "[mysqld]" 下增长参数:
bind-address = 0.0.0.0 port=3306 # skip-grant-tables
并重启 mysql。
重启 mysql: service mysql restart
查看 mysql 状态: service mysql status
中止mysql: service mysql stop
启动mysql: service mysql start
第十步
发现登陆 mysql 必须使用 sudo, workbench链接不上,打算建立新用户来解决问题:
// 建立新用户, 发现报错, 密码不符合要求,打算修改密码校验规则 CREATE USER 'tony'@'%' IDENTIFIED BY '123'; ERROR 1819 (HY000): Your password does not satisfy the current policy requirements // 查看密码校验规则, 展现的密码规则是修改后的规则 mysql> SHOW VARIABLES LIKE 'validate_password%'; +--------------------------------------+--------+ | Variable_name | Value | +--------------------------------------+--------+ | validate_password_check_user_name | ON | | validate_password_dictionary_file | | | validate_password_length | 3 | | validate_password_mixed_case_count | 0 | | validate_password_number_count | 0 | | validate_password_policy | MEDIUM | | validate_password_special_char_count | 0 | +--------------------------------------+--------+ // 修改密码校验规则全局变量 set global validate_password_length=3; set global validate_password_mixed_case_count=0; set global validate_password_number_count=0; set global validate_password_special_char_count=0; // 从新建立用户,任何地方均可链接: '%', 密码: '123' CREATE USER 'tony'@'%' IDENTIFIED BY '123'; // 授予全部权限,并刷新 GRANT ALL PRIVILEGES ON * . * TO 'tony'@'%'; flush privileges;
再次使用 WorkBench 能链接上了。
查看用户 "tony" 信息:
*************************** 1. row *************************** user: tony host: % authentication_string: *23AE809DDACAF96AF0FD78ED04B6A265E05AA257 plugin: mysql_native_password *************************** 2. row ***************************
登陆mysql:
mysql -u tony -p password: 123