syntax works with mysql 5.7 and 8 above
Create mysql user with password
CREATE USER ‘user1’@’localhost’ IDENTIFIED WITH mysql_native_password by ‘<UNIQUEPASSWORD>’;
from linuxcommad line
sudo mysql -e “CREATE USER ‘newrelic’@’localhost’ IDENTIFIED BY ‘YOUR_SELECTED_PASSWORD’;”
create user with ssha method
CREATE USER ‘user1’@’localhost’ IDENTIFIED WITH caching_sha2_password by ‘<UNIQUEPASSWORD>’;
change user password
ALTER USER ‘root’@’localhost’ IDENTIFIED WITH mysql_native_password BY ‘new-Root-Password’;
ALTER USER ‘newrelic’@’localhost’ IDENTIFIED WITH caching_sha2_password BY ‘new-Root-Password’;
ALTER USER ‘newrelic’@’127.0.0.1’ IDENTIFIED WITH caching_sha2_password BY ‘Raazk23-234’;
note: client & server mysql authentication should be same.
grant all permissions
Gant selectec permissions
view user permissions
Set user limits
ALTER USER ‘datadog’@’localhost’ WITH MAX_USER_CONNECTIONS 5;
flush privileges
to reflect changes
FLUSH PRIVILEGES;
view mysql users and password strings
SELECT User, Host, Password, FROM mysql.user;
mysql> SELECT User, Host, Password, FROM mysql.user;
ERROR 1064 (42000): You have an error in your SQL syntax;
password column removed in mysql 8.
mysql list users
mysql user authentication_string,plugin
+——————+————————————————————————+———————————-+—————-+
| user | authentication_string | plugin | host |
+——————+————————————————————————+———————————-+—————-+
| newrelic | Raazk23@#123 | 91666d34772ac6ae86c4a466af4569fc | % |
| phpmyadmin | *31C3E34632FBE2ADBF5B1AB04F8951355194A9C1 | mysql_native_password | % |
| newrelic | *549675EE947E8DC1766DC10C75202B61B4177F1E | mysql_native_password | 127.0.0.1 |
| zzz | *5FEB9D1EA7A2BFB0D7AACE1E96C11F561633AAF1 | mysql_native_password | 127.0.0.1 |
| newrelic | *5FEB9D1EA7A2BFB0D7AACE1E96C11F561633AAF1 | mysql_native_password | 128.199.25.144 |
| datadog | *5FEB9D1EA7A2BFB0D7AACE1E96C11F561633AAF1 | mysql_native_password | localhost |
| mysql.infoschema | $A$005$THISISACOMBINATIONOFINVALIDSALTANDPASSWORDTHATMUSTNEVERBRBEUSED | caching_sha2_password | localhost |
| mysql.session | $A$005$THISISACOMBINATIONOFINVALIDSALTANDPASSWORDTHATMUSTNEVERBRBEUSED | caching_sha2_password | localhost |
| mysql.sys | $A$005$THISISACOMBINATIONOFINVALIDSALTANDPASSWORDTHATMUSTNEVERBRBEUSED | caching_sha2_password | localhost |
| newrelic | *5FEB9D1EA7A2BFB0D7AACE1E96C11F561633AAF1 | mysql_native_password | localhost |
| raazk | *EC950D53E4A6704732C18B19D3C3B53934B03FBB | mysql_native_password | localhost |
| root | *31C3E34632FBE2ADBF5B1AB04F8951355194A9C1 | mysql_native_password | localhost |
+——————+————————————————————————+———————————-+—————-
view mysql user table columns mysql
SHOW COLUMNS FROM my_table;
SHOW COLUMNS FROM mysql.user;
SHOW COLUMNS FROM mysql;
| plugin | char(64) | NO | | ca ching_sha2_password | |
| authentication_string | text | YES | | NU LL | |
| password_expired | enum(‘N’,’Y’) | NO | | N
mysql delete remove user
mysql> DROP USER newrelic;
related Access denied for user root
warning Plugin sha256_password reported
default_authentication_plugin = mysql nATIVE,
monitoring tool was indeed the culprit !
INSTALL PLUGIN CONNECTION_CONTROL
helps to identify the user, mycase grafana.
sudo systemctl stop grafana-agent.service