Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ## Mysql
- Create the directory
- ```bash
- mkdir -p ~/.dockerdata/mysql/my.cnf.d/
- ```
- Create a file with to set a custom mysql configuration
- ```
- touch ~/.dockerdata/mysql/my.cnf.d/custom.cnf
- ```
- Write the configuration bellow:
- ```
- [client]
- default-character-set=utf8
- [mysql]
- default-character-set=utf8
- [mysqld]
- collation-server = utf8_unicode_ci
- character-set-server = utf8
- default_authentication_plugin = mysql_native_password
- ```
- Create Mysql container
- ```
- docker run --name mysql -v ~/.dockerdata/mysql/my.cnf.d/:/etc/my.cnf.d -e MYSQL_ROOT_PASSWORD="root" -p 3306:3306 -d mysql/mysql-server:5.7
- ```
- Access mysql container bash
- ```
- docker exec -it mysql bash
- ```
- Grant ownership to mysql user
- ```
- chown -R mysql:mysql /var/lib/mysql
- ```
- Access mysql from container, update hosts and grant all privileges to root;
- ```
- mysql -uroot -proot
- UPDATE user SET Host='%' WHERE User='root';
- GRANT ALL PRIVILEGES ON *.* TO root@'%' WITH GRANT OPTION;
- FLUSH PRIVILEGES;
- ```
- Restart mysql container
- ```
- docker restart mysql
- # or
- docker stop mysql; docker start mysql;
- ```
Add Comment
Please, Sign In to add comment