среда, 22 марта 2017 г.

MySQL notes

All "recipes" from this post are for FreeBSD (10.3).

How to completely change MySQL 5.6 with 5.7?

NB, please, that this approach will cause wiping of all MySQL data from your host.
  1. sudo pkg remove mysql56-client # will remove the server too
  2. sudo rm -rd /var/db/mysql /usr/local/etc/mysql
  3. sudo pkg install mysql57-server # will install the client too

Start MySQL

  1. sudo service mysql-server onestart

Auto start MySQL after the system boots

  1. sudo cp /etc/rc.conf /etc/rc.conf.old
  2. echo 'mysql_enable="YES"' >> /etc/rc.conf

First time login as DB server admin

  1. sudo cat /root/.mysql_secret # remember the PASSWORD
  2. mysql -u root -p # type the PASSWORD from /root/.mysql_secret

Reset password before usage of MySQL

Execute the next request in the MySQL monitor.
  • SET PASSWORD = PASSWORD('vs?!h(y=/!er');

Create a regular user account

  • CREATE USER IF NOT EXISTS 'vasilyb'@'localhost' IDENTIFIED BY '21212121' PASSWORD EXPIRE;

Remove a user account

  • DROP USER 'jeffrey'@'localhost';