mysql> create database databasename;
To create a MySQL database on a server using the Unix shell, you can use the mysqladmin
or mysql
command-line tools. Here’s an example using the mysql
command:
- Open a terminal on your Unix-based system.
- Log in to the MySQL server using the following command. You will be prompted to enter the MySQL user password.
bash
mysql -u username -p
Replace “username” with your MySQL username.
- Once you are logged in, you can create a new database using the following SQL command:
sql
CREATE DATABASE your_database_name;
Replace “your_database_name” with the desired name for your database.
- After creating the database, you can exit the MySQL shell by typing:
sql
exit;
Or you can use the shortcut:
sql\q
Alternatively, you can use the mysqladmin
command to create a database:
bash
mysqladmin -u username -p create your_database_name
Again, replace “username” with your MySQL username and “your_database_name” with the desired name for your database.
Remember to replace placeholders with your actual values, and ensure that you have the necessary permissions to create databases on the MySQL server.