How do I create an empty database in MySQL?

8:46 PM

To create a database in MySQL and be able to access it you need to run a few commands:

Create the Actual Database

  1. Login into the MySQL as root or as appropriate:
    • mysql -uroot -p -h localhost
    • This logs into the localhost using root as the username and being prompted for the password
  2. Run the actual database create command:
    • CREATE DATABASE database_name;
      NOTE - If customer has not provided any information about schema then character set will be set to default. Default character set is Latin-1.
      OR
    • CREATE DATABASE database_name DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci;
      NOTE - Please cross check with customer while creating new database. I have taken the example of utf8 here.
    • You can check the existing character set/schema by typing following command
      mysql> show create database database_name\G
      
      or 
      
      mysql> show create schema database_name\G
      

Assign a MySQL User to Connect to MySQL

  1. Login into MySQL as noted above
  2. Grant privileges to a MySQL use to login into the database
    • GRANT ALL PRIVILEGES on dbname.* to 'username'@ipaddress;
      NOTE - This will grant full privileges for the specified user to hit in this case the IP Address "from" the server its coming from remotely; Alternate rights can also be granted if the user is to be read only or have limited rights to do database actions.

You Might Also Like

0 comments

Contact Form

Name

Email *

Message *

Translate

Wikipedia

Search results