MySQL

Start
$ sudo /etc/init.d/mysql start
$ sudo service mysql stop

Login:mdp - phpmyadmin:root

Se connecter

$ sudo su
$ mysql

then

mysql >
Exemple

Connaitre la liste des utilisateurs de MySQL

mysql > SELECT User FROM mysql.user;
+------------------+
| User             |
+------------------+
| debian-sys-maint |
| mysql.session    |
| mysql.sys        |
| phpmyadmin       |
| root             |
+------------------+
5 rows in set (0.00 sec)

Supprimer MySQL

sudo service mysql stop  #or mysqld
sudo killall -9 mysql
sudo killall -9 mysqld
sudo apt-get remove --purge mysql-server mysql-client mysql-common
sudo apt-get autoremove
sudo apt-get autoclean
sudo deluser -f mysql
sudo rm -rf /var/lib/mysql
sudo apt-get purge mysql-server-core-5.7
sudo apt-get purge mysql-client-core-5.7
sudo rm -rf /var/log/mysql
sudo rm -rf /etc/mysql

single line

sudo service mysql stop && sudo killall -9 mysql && sudo killall -9 mysqld && sudo apt-get remove --purge mysql-server mysql-client mysql-common && sudo apt-get autoremove && sudo apt-get autoclean && sudo deluser mysql && sudo rm -rf /var/lib/mysql && sudo apt-get purge mysql-server-core-5.7 && sudo apt-get purge mysql-client-core-5.7 && sudo rm -rf /var/log/mysql && sudo rm -rf /etc/mysql

https://stackoverflow.com/questions/10853004/removing-mysql-5-7-completely/16178696#16178696

Réparer mysql

https://forum.ubuntu-fr.org/viewtopic.php?id=1999553

PHPMyAdmin

https://askubuntu.com/questions/55280/phpmyadmin-is-not-working-after-i-installed-it Go to http://localhost/phpmyadmin

Mot de passe de connexion MySQL pour phpmyadmin phpmyadmin:ctVic2011

Grant privileges to user phpmyadmin

https://askubuntu.com/questions/763336/cannot-enter-phpmyadmin-as-root-mysql-5-7#763359

Connect to MySQL

$ mysql -u username -h localhost -p

ça fonctionne… On a :

MariaDB [(none)]> 

MariaDB est un fork de MySQL

Voir les bases

MariaDB [(none)]> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| phpmyadmin         |
+--------------------+

Utiliser une database particulière

MariaDB [(none)]> use performance_schema;
MariaDB [performance_schema]>

create user

MariaDB [(none)]> CREATE USER 'usename'@'localhost' IDENTIFIED BY 'password';

Puis

MariaDB [(none)]>  GRANT ALL PRIVILEGES ON * . * TO 'username'@'localhost';

hash password / retrieve hashed password

Avec https://www.mysql-password.com/hash

change password

MariaDB [(none)]> ALTER USER 'username'@'localhost' IDENTIFIED BY 'password'

grant privileges to user

MariaDB [(none)]> GRANT ALL PRIVILEGES ON database_name.* TO 'username'@'localhost';