Here you can find the information about MySQL users, databases and user privileges management with the help of command line interface (CLI).
Use the instructions for VPS and Dedicated servers only.
[notice type=”warning”] You should have root privileges (administrative access) to be able to manipulate databases and users via SSH.
Create new database, user and grant permissions
1. Set up a connection with remote server over SSH.
2. Enter the following command to access MySQL:
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
The password is specified in the root/.my.cnf file on the server (typically).
Use the following command to retrieve the password:
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
The command prompt now starts with mysql tag and angle bracket “>” instead of the dollar sign.
5. To create a new database, use the following command:
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
username – the name of the MySQL user which will be created
user_password – the password which we want to assign to that user
The 'username'@'localhost' account can be used only when connecting from the local host.
7. Now we have to grant all permissions to the new user.
The commands will help to do that:
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
These privileges applies to ALL example_database tables to the username.
To list all your databases and users, do the following:
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Upload sample data SQL file to any directory on your remote server, you need to do the next:
1.cd(change directory)to the Magento installation directory.
2. Run the following command to import the SQL file:
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters