In MySQL, schemas are synonyms of databases.Although it is true that we are talking about programming with databases as an opening, we also say that “MySQL Workbench” has a very useful section in the administration of data servers and we present it as a frame of reference for our goal to monitor the handling and storage of our information, join us! Prerequisites.Use the CREATE DATABASE statement to create a new database.Now, you can work with testdb2 from the MySQL Workbench. The testdb2 node is open as shown in the following screenshot. Seventh, to select the testdb2 database, (1) right-click the database name and (2) choose Set as Default Schema menu item: If everything is fine, you will see the new database created and showed in the schemas tab of the Navigator section. Note that the CREATE SCHEMA statement command has the same effect as the CREATE DATABASE statement. Sixth, MySQL Workbench opens the following window that displays the SQL script which will be executed. You need to (1) enter the schema name, (2) change the character set and collation if necessary, and click the Apply button: Creating a new schema also means creating a new database.įifth, the following window is open. In MySQL, the schema is the synonym for the database. MySQL Workbench opens the following window which consists of four parts: Navigator, Query, Information, and Output.įourth, click the create a new schema in the connected server button from the toolbar: Third, double-click the connection name Local to connect to the MySQL Server. You need to (1) type the password for the root user, (2) check the Save password in vault, and (3) click OK button. MySQL Workbench displays a dialog asking for the password of the root user: Second, type the name for the connection and click the Test Connection button. To create a new database using the MySQL Workbench, you follow these steps:įirst, launch the MySQL Workbench and click the setup new connection button as shown in the following screenshot: Output: Bye Creating a new database using MySQL Workbench To quit the mysql program, type exit command: exit Code language: PHP ( php ) Now, you can start creating tables and other databases objects within the testdb database. | testdb | CREATE DATABASE `testdb` /*!40100 DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci */ /*!80016 DEFAULT ENCRYPTION='N' */ |ġ row in set (0.01 sec) Code language: JavaScript ( javascript )įinally, select the newly created database to work with by using the USE statement: USE testdb Code language: SQL (Structured Query Language) ( sql ) MySQL returns the database name and the character set and collation of the database: +-+-+ 02 sec) Code language: CSS ( css )Īfter that, use the SHOW CREATE DATABASE command to review the created database: SHOW CREATE DATABASE testdb Code language: SQL (Structured Query Language) ( sql ) It’ll return the following: Query OK, 1 row affected (0. Then, issue the CREATE DATABASE command with a database name e.g., testdb and press Enter: CREATE DATABASE testdb SHOW DATABASES ĥ rows in set (0.00 sec) Code language: JavaScript ( javascript ) Next, display the current databases available on the server using the SHOW DATABASES statement. To authenticate, you need to type the password for the root user account and press the Enter key. It’ll prompt you for entering a password. To create a new database via the mysql client tool, you follow these steps:įirst, log in to the MySQL Server using a user account that has the CREATE DATABASE privilege: mysql -u root -p Code language: SQL (Structured Query Language) ( sql ) If you skip the CHARACTER SET and COLLATE clauses, MySQL will the default character set and collation for the new database.Ĭreating a new database using the mysql client tool
0 Comments
Leave a Reply. |