SHOW VARIABLES LIKE '%time_zone%' SELECT NOW() AS now, UTC_TIMESTAMP() AS utc_now
config
max_connections = 100 SHOW STATUS LIKE 'Max_used_connections' SHOW STATUS LIKE 'Threads_connected';
/etc/mysql/my.cnf /etc/mysql/mysql.conf.d/mysqld.cnf
connect if no root user
1. etc\mysql\mysql.conf.d\mysqld.cnf -> [mysqld] -> add line:
skip-grant-tables
2. systemctl restart mysql
3. run: mysql
4. mysql run: FLUSH PRIVILEGES;
5. create user 'root'@'localhost';
6. grant all on *.* to 'root'@'localhost'
7. update user set `plugin` = 'auth_socket' where `user` = 'root';
8. mysqld.cnf -> remove skip-grant-tables
9. systemctl restart mysql
10 run: mysql
11. mysql run: SELECT CURRENT_USER();
https://dev.mysql.com/doc/refman/8.0/en/resetting-permissions.html#resetting-permissions-unix
access to remote host
1. mysqld.cnf
bind-address = 0.0.0.0
2. mysql:
create user 'admin'@'%' identified by 'my-password';
GRANT ALL PRIVILEGES ON *.* TO 'admin'@'%';
3. if ufw exists ufw allow mysql (3306/tcp) https://www.youtube.com/watch?v=DjUD7_mJJPE
replace text on field
UPDATE `products` SET `description` = REPLACE(`description`, 'pripuciami_baseinai', 'pripuciamibaseinai')
mysqldump
mysqldump -u root -p dbname > \var\copy.sql
max_connections
* phpmyadmin -> Variables -> max_connections
install mysql server+client
apt install mysql-server mysql-client -y
Failed to restart mysql.service: Unit mysql.service is masked
systemctl unmask mysql.service service mysql start
show-create-grant-databases
Login 1. mysql -u myusername -p OR mysql (root user) 2. enter password 3. mysql> SHOW DATABASES; Create&Drop database 1. mysql> CREATE DATABASE database_name; 1.1. mysql> CREATE DATABASE db_name CHARACTER SET utf8 COLLATE utf8_general_ci; 2. mysql> DROP DATABASE database_name; Show grants 1. mysql> SHOW GRANTS; 1. mysql> SHOW GRANTS username; Grant database - from root user 1. mysql> GRANT ALL PRIVILEGES ON db_name.* TO 'username'@'localhost'; ALL PRIVILEGES: CREATE, DELETE DB etc mysql> GRANT ALL PRIVILEGES ON *.* TO 'username'@'localhost'; p.s. always write ; at the end https://linuxize.com/post/how-to-show-databases-in-mysql/ https://www.mysqltutorial.org/mysql-create-database/