MySQL / MariaDB

How to restart MySQL/MariaDB service

Replace mysql with mysqld for RedHat-based platforms.

Ubuntu 16.10 and later, RedHat/CentOS 7 and later, fedora and other platform with systemd

sudo systemctl restart mysql.service …
Read More

How to reset MySQL/MariaDB root password

MySQL is one of the world's most popular open-source databases. It is mainly used on many database-enabled websites, mostly for being free and powerful.

If you happen …
Read More

How to import CSV files to MySQL/MariaDB table

You can import data from CSV (Comma-Separated Values) files directly to MySQL tables using LOAD DATA statement or by using MySQL's own mysqlimport tool.

To be able …
Read More

How to create MySQL/MariaDB user

User accounts can be created by using MySQL's GRANT statement. For this, you'll need to login to MySQL using the root account, which has full privilege on the mysql.user
Read More

How to connect to root MySQL account without sudo

You can only connect to root account for both MySQL and MariaDB if you are logged in to the system as root user or by using sudo. If not, …
Read More

MySQL/MariaDB configuration files

/etc/mysql/my.cnf, /etc/my.cnf or ~/my.cnf

How to clone MySQL / MariaDB table

You can duplicate a table in MySQL or MariaDB by creating a new table with the same structure as the source table and then copying the data or rows …
Read More

How to configure table name case sensitivity for MySQL or MariaDB

MariaDB and MySQL table name is case sensitive if it's running on case-sensitive systems such as in Linux and Unix. Windows however does not enforce case sensitivity for its …
Read More

MySQL configuration files

/etc/mysql/my.cnf, /etc/my.cnf or ~/my.cnf

How to create MySQL user

User account can be created by using MySQL’s GRANT statement. For this, you’ll need to login to MySQL using the root account, which has full privilege on the mysql.user table.

The following statement will create a user account named myusername which will have full access to the mydatabase database from localhost and set the password to mypassword

 GRANT ALL ON mydatabase.* TO 'myusername'@'localhost' IDENTIFIED BY 'mypassword';