Home mysql - troubleshooting
Post
Cancel

mysql - troubleshooting

Determine which MySQL configuration file is being used

How do I find the MySQL my.cnf location

  • /etc/my.cnf

  • /etc/mysql/my.cnf

  • $MYSQL_HOME/my.cnf

  • [datadir]/my.cnf

  • ~/.my.cnf

1
mysql --verbose --help | grep -A 1 "Default options"
1
2
Default options are read from the following files in the given order:
/etc/mysql/my.cnf /etc/my.cnf ~/.my.cnf 

Getting, Installing, and Upgrading MariaDB

HOW TO REMOVE MYSQL ENTIRELY FROM LINUX SYSTEM(CENTOS)

1
2
3
sudo yum remove mysql mysql-server
mv /var/lib/mysql /var/lib/mysql_bkup
yum install mysql mysql-server

How To Reset Your MySQL or MariaDB Root Password

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
mysql --version
sudo systemctl stop mysql // for mysql
sudo systemctl stop mariadb // for mariadb

sudo mysqld_safe --skip-grant-tables --skip-networking & // Start the database without loading the grant tables or enabling networking:

mysql -u root // Now you can connect to the database as the root user, which should not ask for a password.

FLUSH PRIVILEGES;// Let’s tell the database server to reload the grant tables by issuing the FLUSH PRIVILEGES command.

ALTER USER 'root'@'localhost' IDENTIFIED BY 'new_password';

sudo kill `sudo cat /var/run/mysqld/mysqld.pid` // for mysql
sudo kill `/var/run/mariadb/mariadb.pid` // for maridab

sudo systemctl start mysql // for mysql
sudo systemctl start mariadb // for mariadb

mysql -u root -p // Now you can confirm that the new password has been applied correctly by running:

Failed to start mariadb database server

1
2
3
4
sudo mkdir /var/lib/mysql
sudo chown mysql:mysql /var/lib/mysql/
sudo systemctl start mariadb.service
mysql_secure_installation

Mysql command not found in OS X 10.7

1
2
# mysql
export PATH=/usr/local/mysql/bin/:$PATH
This post is licensed under CC BY 4.0 by the author.