Difference between revisions of "MySQL"

From Wasya Wiki
Jump to: navigation, search
Line 1: Line 1:
  
 +
= Install =
 +
== Configure ==
 
Don't forget to change bind_ip in /etc/mysql/my.cfg to 0.0.0.0!
 
Don't forget to change bind_ip in /etc/mysql/my.cfg to 0.0.0.0!
  
Line 13: Line 15:
 
   FLUSH PRIVILEGES;
 
   FLUSH PRIVILEGES;
  
=== With Docker ===
+
== Create a user ==
 +
# CREATE USER 'sammy'@'localhost' IDENTIFIED BY 'password'; ## may or may not work with php ?
 +
CREATE USER 'sammy'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password';
 +
ALTER USER 'sammy'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password';
  
From: https://hub.docker.com/_/mysql/
+
GRANT <PRIVILEGE>, <PRIVILEGE> ON database.table TO 'username'@'host';
 +
GRANT CREATE, ALTER, DROP, INSERT, UPDATE, DELETE, SELECT, REFERENCES, RELOAD on *.* TO 'sammy'@'localhost' WITH GRANT OPTION;
 +
GRANT ALL PRIVILEGES ON *.* TO 'sammy'@'localhost' WITH GRANT OPTION;
  
  docker run --name some-mysql -e MYSQL_ROOT_PASSWORD=my-secret-pw -d mysql:tag
+
  FLUSH PRIVILEGES;
 
+
where some-mysql is the name you want to assign to your container, my-secret-pw is the password to be set for the MySQL root user and tag is the tag specifying the MySQL version you want. See the list above for relevant tags.
+
  
 +
= Develop =
 
== dump/restore ==
 
== dump/restore ==
 
  mysql -u username -p database_name < file.sql
 
  mysql -u username -p database_name < file.sql

Revision as of 19:50, 1 April 2022

Install

Configure

Don't forget to change bind_ip in /etc/mysql/my.cfg to 0.0.0.0!

Allow root to login from anywhere. From: http://stackoverflow.com/questions/11223235/mysql-root-access-from-all-hosts

CREATE USER 'jeffrey'@'localhost' IDENTIFIED BY 'mypass';
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'password';
FLUSH PRIVILEGES;


 CREATE USER 'bjjc_prod_user'@'%' IDENTIFIED BY '<some-pass>';
 GRANT ALL PRIVILEGES ON bjjc_wordpress.* TO 'bjjc_prod_user'@'%' WITH GRANT OPTION;
 FLUSH PRIVILEGES;

Create a user

# CREATE USER 'sammy'@'localhost' IDENTIFIED BY 'password'; ## may or may not work with php ?
CREATE USER 'sammy'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password';
ALTER USER 'sammy'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password';
GRANT <PRIVILEGE>, <PRIVILEGE> ON database.table TO 'username'@'host';
GRANT CREATE, ALTER, DROP, INSERT, UPDATE, DELETE, SELECT, REFERENCES, RELOAD on *.* TO 'sammy'@'localhost' WITH GRANT OPTION;
GRANT ALL PRIVILEGES ON *.* TO 'sammy'@'localhost' WITH GRANT OPTION;
FLUSH PRIVILEGES;

Develop

dump/restore

mysql -u username -p database_name < file.sql