mysql数据库授权

43 2025-04-12 15:28

docker ps

 

 

docker exec -it mysql /bin/bash

mysql -u root -p

docker exec -it tomcat /bin/bash

cd /usr/local/tomcat

rm -rf webapps

cp -r webapps.dist/* webapps/

docker cp tomcat:/user/local/tomcat/conf/tomcat-users.xml /mnt/user21temp

docker cp /mnt/user21temp tomcat:/user/local/tomcat/conf/tomcat-users.xml


docker logs tomcat

 

docker cp tomcat:/usr/local/tomcat/conf/context.xml /mnt/user1/context.xml

docker cp /mnt/user1/context.xml tomcat:/usr/local/tomcat/conf/context.xml

docker cp mysql:/etc/mysql/mysql.cnf /mnt/user21temp

 

mysql> SHOW DATABASES;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| my_jpressdb        |
| mysql              |
| performance_schema |
| sys                |
+--------------------+
5 rows in set (0.02 sec)

mysql> USE my_jpressdb;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql> SHOW TABLES;

mysql> SHOW GRANTS FOR 'root'@'%';
+-------------------------------------------------------------+
| Grants for root@%                                           |
+-------------------------------------------------------------+
| GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' WITH GRANT OPTION |
+-------------------------------------------------------------+
1 row in set (0.00 sec)

mysql> GRANT ALL PRIVILEGES ON my_jpressdb.* TO 'root'@'%' IDENTIFIED BY 'admin21';
Query OK, 0 rows affected, 1 warning (0.01 sec)

mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)

mysql> SHOW GRANTS FOR 'root'@'%';
+-------------------------------------------------------------+
| Grants for root@%                                           |
+-------------------------------------------------------------+
| GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' WITH GRANT OPTION |
| GRANT ALL PRIVILEGES ON `my_jpressdb`.* TO 'root'@'%'       |
+-------------------------------------------------------------+
2 rows in set (0.00 sec)

 

全部评论

·