安裝并初始化MySql
sudo pacman -S mysql
正在安裝 mysql-clients (8.0.11-1)...
正在安裝 mysql (8.0.11-1)...
:: You need to initialize the MySQL data directory prior to starting
the service. This can be done with mysqld --initialize command, e.g.:
mysqld --initialize --user=mysql --basedir=/usr --datadir=/var/lib/mysql
:: Additionally you should secure your MySQL installation using
mysql_secure_installation command after starting the mysqld service
初始化MySql數(shù)據(jù)目錄/注意記錄root臨時(shí)密碼
mysqld --initialize --user=mysql --basedir=/usr --datadir=/var/lib/mysql
查看MySql狀態(tài)
sudo systemctl status mysqld
啟動MySql服務(wù)/開機(jī)自啟
sudo systemctl enable mysqld
sudo systemctl start mysqld
賬戶安全設(shè)置/需要使用root臨時(shí)密碼登陸
mysql_secure_installation
使用workbench連接時(shí)需要修改密碼規(guī)則
#出現(xiàn)
caching_sha2_password cannot be loaded
ALTER USER 'root'@'localhost' IDENTIFIED BY 'password' PASSWORD EXPIRE NEVER; #修改加密規(guī)則
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password'; #更新一下用戶的密碼
FLUSH PRIVILEGES; #刷新權(quán)限
再重置下密碼:alter user 'root'@'localhost' identified by '123qwe';
ERROR(重新安裝后已解決)
Can't connect to local MySQL server through socket '/run/mysqld/mysqld.sock' (2)
● mysqld.service - MySQL database server
Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
Active: activating (start-post) (Result: exit-code) since Sat 2018-05-26 19:41:34 CST; 18s ago
Process: 8359 ExecStart=/usr/bin/mysqld --pid-file=/run/mysqld/mysqld.pid (code=exited, status=1/FAILURE)
Main PID: 8359 (code=exited, status=1/FAILURE); Control PID: 8360 (mysqld-post)
Tasks: 2 (limit: 4722)
Memory: 1.2M
CGroup: /system.slice/mysqld.service
├─8360 /bin/sh /usr/bin/mysqld-post
└─8560 sleep 1
5月 26 19:41:35 dexter0ion-pc mysqld[8359]: 2018-05-26T11:41:34.907694Z 0 [Warning] [MY-010139] [Server] Changed limits: >
5月 26 19:41:35 dexter0ion-pc mysqld[8359]: 2018-05-26T11:41:34.907742Z 0 [Warning] [MY-010142] [Server] Changed limits: >
5月 26 19:41:35 dexter0ion-pc mysqld[8359]: 2018-05-26T11:41:35.121790Z 0 [Warning] [MY-010915] [Server] 'NO_ZERO_DATE', >
5月 26 19:41:35 dexter0ion-pc mysqld[8359]: 2018-05-26T11:41:35.121870Z 0 [System] [MY-010116] [Server] /usr/bin/mysqld (>
5月 26 19:41:35 dexter0ion-pc mysqld[8359]: 2018-05-26T11:41:35.123947Z 0 [Warning] [MY-010091] [Server] Can't create tes>
5月 26 19:41:35 dexter0ion-pc mysqld[8359]: 2018-05-26T11:41:35.123965Z 0 [Warning] [MY-010159] [Server] Setting lower_ca>
5月 26 19:41:35 dexter0ion-pc mysqld[8359]: 2018-05-26T11:41:35.124479Z 0 [ERROR] [MY-010172] [Server] failed to set data>
5月 26 19:41:35 dexter0ion-pc mysqld[8359]: 2018-05-26T11:41:35.124653Z 0 [ERROR] [MY-010119] [Server] Aborting
5月 26 19:41:35 dexter0ion-pc mysqld[8359]: 2018-05-26T11:41:35.124793Z 0 [System] [MY-010910] [Server] /usr/bin/mysqld: >
5月 26 19:41:35 dexter0ion-pc systemd[1]: mysqld.service: Main process exited, code=exited, status=1/FAILURE
~