MySql's Articles

MySQL is an open-source relational database management system. Its name is a combination of "My", the name of co-founder Michael Widenius's daughter, and "SQL", the abbreviation for Structured Query Language.

How to Import SQL Files into a MySQL database using Command Line
In this article, I will share with you how to import multiple SQL files in the database at the same time using a command line. many developers don't know how the import more than one file at the same time using the command line in ubuntu. so, here I will share one trick for this problem. If you have multiple SQL files in one folder and you want to import that all at the same time so, no need to waste your time. please follow the simple steps. Merge all file into one file First, we need to merge that all SQL files into one single file using the below ubuntu command. cat *.sql > all_files.sql then import that file in your selected database using the following command. Login mySql sudo mysql -u root -p then hit the Enter and put your MySQL password. Select Database use your_database_name Import selected SQL file source path_your_sql_file i hope you like this article.
Fix recovery pending state in SQL server database
When you can't access one or multiple file access to SQL server, there may be issue SQL server is corrupted. The error may be due to: The database couldn't be shut down properly. Due to insufficient space or hard disk space. If the primary database files are corrupted, the user will face this problem. It may be when you change the state from offline to online. In this article, I will show you how to fix recovery pending state in SQL server. Follow bellow steps to resolve SQL server database issue. Open SQL command line and run the below query one by one to resolve it. ALTER DATABASE db_name SET EMERGENCY; ALTER DATABASE db_name set single_user; DBCC CHECKDB (db_name, REPAIR_ALLOW_DATA_LOSS) WITH ALL_ERRORMSGS; ALTER DATABASE db_name set multi_user; Now refresh the database and you will see the error is fixed. I hope you liked this article.
Client does not support authentication protocol requested by server; consider upgrading MySQL client
Recently I was working on Node.js application. In my application, I faced connection issue with MySQL server. Everything was good still I was getting following error. Error: ER_NOT_SUPPORTED_AUTH_MODE: Client does not support authentication protocol requested by server; consider upgrading MySQL client In this article, I will show you why this error occured and how to solve this error. While going through Googling the issue, I came to know that MySQL 8.0 is using caching_sha2_password authentication plugin rather than mysql_native_password and Node.js Mysql package uses mysql_native_password authentication plugin. Solution: In this situation, either you can change current user password according to mysql_native_password authentication plugin or you need to create new user with mysql_native_password authentication plugin. Change current user password to authentication plugin To change current user password to mysql_native_password authentication plugin, you need to login to MySQL command line and run the following command. Note that root is username and password is the password for that user. ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password'; Don't forget to flush privileges: FLUSH PRIVILEGES; And that's it, logout to MySQL command line: quit; Add new user with mysql_native_password authentication plugin: To create a new user, login to MySQL command line and run the following command with username and password. CREATE USER 'newuser'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password'; You may need to grant privileges to new user. If you want to give all privileges, run the following query. GRANT ALL PRIVILEGES ON *.* TO ‘newuser’@'localhost'; Or you may grant specific privileges with following query: GRANT CREATE, SELECT, INSERT ON *.* TO ‘newuser’@'localhost'; And reload the privileges: FLUSH PRIVILEGES; And close the MySQL connection: quit; After that, you can connect Node.js application with MySQL. I hope this article will help you on your development.
How to import an SQL file in MySQL
While working on web application, often you need to insert data from sql file. Also when changing your server, you need to export database from old server and import to new one. There are so many ways you can import database from sql file. There are so many GUI applications like MySQL Workbench as well as web application like phpmyadmin available to work with Mysql server. We can also use command line to import file from remote desktop. We will go through few ways to import database from SQL file in MySQL. Import from MySQL Workbench software MySQL Workbench is open-source as well as Community Edition visual database management software developed by Oracle Corporation. The Community Edition is a full featured product still we can do all basic stuff in Open-source software. We will use Open-source software to import sql file. First create the connection on MySQL Workbench dashboard and lauch the server. If you want to create new database, click Create New Schema button from menubar, write database name and apply the changes. To import the SQL file from local system, click File > Run SQL Script... Select the database name and default character set like utf8 and click Run button. This will execute the query. Import from phpMyAdmin phpMyAdmin is free and open-source web application written in PHP. It is easy to manage MySQL and MariaDB database through phpMyAdmin. Many web hosting providers provides phpMyAdmin tool to manage database. If they not provide phpMyAdmin, we can simply install from the official phpMyAdmin Link[]. This is simple way to import SQL file. First, from your browser login to server phpMyAdmin portal either through Cpanel menu or from your database server link. Now from the left bar select the database where you want to import the sql file. Now click Import option from menubar. Select the file from file input and click Go button. This will run SQL file to database server. Import through Command line This is fast way to import SQL script but it is sometimes not easy and takes time to run proper command line. If you have enough knowledge about bash script and MySQL commands, this will be easiest way. To import the SQL script file, run below command from your Terminal. mysql -u database_user -p -h database_name < path/to/sql_file.sql If this not work for you, first connect to ssh and append mysql command. ssh remote_user@remote_server mysql -u database_user -ptestpass database_name < path/to/sql_file.sql There is also one method to import sql file through command line. First upload the sql file to remote server through git or FTP application like FileZilla and you can directly import database. mysql -u database_user -p database_name < path/to/sql_file.sql So, this way sql file can be import to remote server. These are just few ways, there are many softwares available to import the sql file. I hope it will help you.