mysql無法用root遠端登入解決方案
來源:https://askubuntu.com/questions/763336/cannot-enter-phpmyadmin-as-root-mysql-5-7
說明:
自MySQL 5.7後登錄MySQL的root帳號需要sudo
故無法使用root登錄
解決方法:新建使用者 > 允許遠端連線 > 修改設定檔
執行步驟:
1.先連到MySQL
sudo mysql --user=root mysql
2.為phpMyAdmin創建一個使用者 註:phpmyadmin為帳號 some_pass為密碼
CREATE USER 'phpmyadmin'@'localhost' IDENTIFIED BY 'some_pass';
GRANT ALL PRIVILEGES ON *.* TO 'phpmyadmin'@'localhost' WITH GRANT OPTION;
FLUSH PRIVILEGES;
3.允許遠端登入
CREATE USER 'phpmyadmin'@'%' IDENTIFIED BY 'some_pass';
GRANT ALL PRIVILEGES ON *.* TO 'phpmyadmin'@'%' WITH GRANT OPTION;
FLUSH PRIVILEGES;
4.更改phpMyAdmin設定檔
sudo vim /etc/dbconfig-common/phpmyadmin.conf
# dbc_dbuser: database user
# the name of the user who we will use to connect to the database.
dbc_dbuser='phpmyadmin'
# dbc_dbpass: database user password
# the password to use with the above username when connecting
# to a database, if one is required
dbc_dbpass='some_pass'
範例
sudo mysql --user=root mysql
CREATE USER 'testuser'@'raspberrypi' IDENTIFIED BY 'testuser';
GRANT ALL PRIVILEGES ON *.* TO 'testuser'@'raspberrypi' WITH GRANT OPTION;
FLUSH PRIVILEGES;
CREATE USER 'testuser'@'%' IDENTIFIED BY 'testuser';
GRANT ALL PRIVILEGES ON *.* TO 'testuser'@'%' WITH GRANT OPTION;
FLUSH PRIVILEGES;
exit;
sudo vim /etc/dbconfig-common/phpmyadmin.conf
最下面加這兩行
dbc_dbuser='testuser'
dbc_dbpass='testuser'
說明:
自MySQL 5.7後登錄MySQL的root帳號需要sudo
故無法使用root登錄
解決方法:新建使用者 > 允許遠端連線 > 修改設定檔
執行步驟:
1.先連到MySQL
sudo mysql --user=root mysql
2.為phpMyAdmin創建一個使用者 註:phpmyadmin為帳號 some_pass為密碼
CREATE USER 'phpmyadmin'@'localhost' IDENTIFIED BY 'some_pass';
GRANT ALL PRIVILEGES ON *.* TO 'phpmyadmin'@'localhost' WITH GRANT OPTION;
FLUSH PRIVILEGES;
3.允許遠端登入
CREATE USER 'phpmyadmin'@'%' IDENTIFIED BY 'some_pass';
GRANT ALL PRIVILEGES ON *.* TO 'phpmyadmin'@'%' WITH GRANT OPTION;
FLUSH PRIVILEGES;
4.更改phpMyAdmin設定檔
sudo vim /etc/dbconfig-common/phpmyadmin.conf
# dbc_dbuser: database user
# the name of the user who we will use to connect to the database.
dbc_dbuser='phpmyadmin'
# dbc_dbpass: database user password
# the password to use with the above username when connecting
# to a database, if one is required
dbc_dbpass='some_pass'
範例
sudo mysql --user=root mysql
CREATE USER 'testuser'@'raspberrypi' IDENTIFIED BY 'testuser';
GRANT ALL PRIVILEGES ON *.* TO 'testuser'@'raspberrypi' WITH GRANT OPTION;
FLUSH PRIVILEGES;
CREATE USER 'testuser'@'%' IDENTIFIED BY 'testuser';
GRANT ALL PRIVILEGES ON *.* TO 'testuser'@'%' WITH GRANT OPTION;
FLUSH PRIVILEGES;
exit;
sudo vim /etc/dbconfig-common/phpmyadmin.conf
最下面加這兩行
dbc_dbuser='testuser'
dbc_dbpass='testuser'
留言
張貼留言