mysql -u user -p your_password
Create user.
*Localhost
CREATE USER 'your_user'@'localhost' IDENTIFIED BY 'your_password';
GRANT ALL PRIVILEGES ON *.* TO 'your_user'@'localhost' WITH GRANT OPTION;
*RemoteAccess
CREATE USER 'your_user'@'your_ip' IDENTIFIED BY 'your_password';
GRANT ALL PRIVILEGES ON *.* TO 'your_user'@'your_ip' WITH GRANT OPTION;
FLUSH PRIVILEGES;
Note: if the access is denied still when you run command line above then you need the configuration file /etc/my.cnf and add next line on the file bind-address:your_ip. and then you need tu restart mysql.
#mysql
systemctl restart mysql
#mariadb
systemctl restart mariadb.service
Next: open the required port 3306, run the next command.
iptables -A INPUT -i eth0 -p tcp --destination-port 3306 -j ACCEPT
In the end: Save the iptables configuration
service iptables save
Create Databases.
CREATE DATABASE your_database;
GRANT ALL PRIVILEGES ON your_database.* TO 'your_user'@'localhost';
References:
https://linuxize.com/post/how-to-create-mysql-user-accounts-and-grant-privileges/
https://www.inmotionhosting.com/support/website/how-to-create-a-database-using-mysql-from-the-command-line/
https://www.hostinger.com/tutorials/mysql/how-to-grant-remote-access-mysql-vps
https://support.infrasightlabs.com/article/host-is-not-allowed-to-connect-to-this-mysql-server/
https://serverfault.com/questions/626922/no-mysqld-or-mysql-server-after-mariadb-server-install
No comments:
Post a Comment