Showing posts with label MySql tutorials. Show all posts
Showing posts with label MySql tutorials. Show all posts

Friday, May 8, 2015

Create a MySQL Database, Username, Password, and Privileges from the command line

Create a MySQL Database, Username, Password, and Privileges from the command line

Step 1: Login to MySQL ( you will need an account )
user@server:~$ mysql -u mysql_user -p
Enter password:
Step 2: Create the Database
mysql > create database db_name;
Step 3: Verify that it’s there
mysql > show databases;
Step 4: Create the User
mysql > create user db_user;
Step 5: Grant privileges while assigning the password
mysql > grant all on db_name.* to 'db_user'@'localhost' identified by 'db_password';
*Note: The localhost field usually doesn’t have to be edited, but you can set it to the specific address.
The above example grants all privileges, obviously. But you will likely want to limit privileges under many circumstances. These parameters include selectinsert, and delete.
Choose all that apply and separate by comma, thusly:
mysql > grant select, insert, delete on db_name.* to 'db_user'@'localhost' identified by 'db_password';

How to Change the MySQL root Password in Linux or OSX via Command Line


How to Change the MySQL root Password in Linux or OSX via Command Line

Stop MySQL
Start it in safe mode:
This will be an ongoing command until the process is finished so open anothershell/terminal window, log in without a password:
Change the lowercase password to what you want – with single quotes.
Start MySQL