I am currently working on a project and am using the MySQL console. The project involves moving an existing codebase and database to a new server. I have ssh and MySQL console user access on the new server.

This assumes you know how to use ssh to connect to the server and have a basic knowledge of MySQL.

 

The words in curly bracesĀ are where you enter your required credentials.

Do not include the curly braces.

Make sure the MySQL console commands end with a semi colon.

 

First, ssh into the new server and type this command to run the MySQL console:

mysql -u {userName} -p

The MySQL console will prompt you for the MySQL password. Enter this and you will be in the MySQL console.

 

To create a new database in the MySQL console type:

create schema {newDatabaseName} ;

 

To create a new user:

create user {newUserName} identified by {newUserPassword} ;

 

Now you have to setup the new user to have permissions to access the new database. Type this in the MySQL console:

grant all privileges on {newDatabaseName}.* to {newUserName};

 

Now for the new privileges to take effect type this in the MySQL console:

flush privileges;

 

Your mileage may vary.

 

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.