Last active
February 7, 2023 18:59
-
-
Save tshabatyn/b7f085d745217994b618f078158ad6b1 to your computer and use it in GitHub Desktop.
Create db and user for it
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# MySQL 8.0 | |
CREATE DATABASE my_db_name CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci; | |
# Edit collation of existing DB | |
ALTER DATABASE my_db_name CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci; | |
# MySQL 5.7 | |
CREATE DATABASE my_db_name CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; | |
# Edit collation of existing DB | |
ALTER DATABASE my_db_name CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci; | |
CREATE USER 'MY_USER'@'localhost' IDENTIFIED BY 'MY_PASSWORD'; | |
GRANT ALL PRIVILEGES ON my_db_name.* TO 'MY_USER'@'localhost'; | |
CREATE USER 'MY_USER'@'127.0.0.%' IDENTIFIED BY 'MY_PASSWORD'; | |
GRANT ALL PRIVILEGES ON my_db_name.* TO 'MY_USER'@'127.0.0.%'; | |
CREATE USER 'MY_USER'@'192.168.1.%' IDENTIFIED BY 'MY_PASSWORD'; | |
GRANT ALL PRIVILEGES ON my_db_name.* TO 'MY_USER'@'192.168.1.%'; | |
CREATE USER 'MY_USER'@'hostname' IDENTIFIED BY 'MY_PASSWORD'; | |
GRANT ALL PRIVILEGES ON my_db_name.* TO 'MY_USER'@'hostname'; | |
FLUSH PRIVILEGES; | |
mysql -h127.0.0.1 -uMY_USER -pMY_PASSWORD my_db_name | |
# Dump old DB to new DB | |
mysqldump -hdbhost -uroot -p old_db_name | mysql -hdbhost -uroot -p my_db_name |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment