Difference between revisions of "MYSQL-notes"

From Wiki at Neela Nurseries
Jump to: navigation, search
(2017-10-19 THU - Ted adding overview section, and section of notes on how to configure two or more MYSQL servers on a given host.)
(MYSQL Reset Root Password)
Line 51: Line 51:
 
</pre>
 
</pre>
  
 +
 +
Commands to grant all privileges to a user and to show privileges of a MYSQL user:
 +
 +
<pre>
 +
 +
user@localhost:~/projects/database-back-ups$ mysql -u root -p
 +
Enter password:
 +
Welcome to the MySQL monitor.  Commands end with ; or \g.
 +
Your MySQL connection id is 3316
 +
Server version: 5.1.54-1ubuntu4 (Ubuntu)
 +
 +
Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
 +
This software comes with ABSOLUTELY NO WARRANTY. This is free software,
 +
and you are welcome to modify and redistribute it under the GPL v2 license
 +
 +
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
 +
 +
mysql> grant all privileges on *.* to 'jose'@'localhost' identified by 'database_pass_phrase' with grant option;
 +
 +
mysql> show grants for 'jose'@'localhost';
 +
 +
+---------------------------------------------------------------------------------------------------------------------------------------+
 +
| Grants for jose@localhost                                                                                                              |
 +
+---------------------------------------------------------------------------------------------------------------------------------------+
 +
| GRANT ALL PRIVILEGES ON *.* TO 'jose'@'localhost' IDENTIFIED BY PASSWORD '*0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ0123' WITH GRANT OPTION |
 +
+---------------------------------------------------------------------------------------------------------------------------------------+
 +
1 row in set (0.00 sec)
 +
 +
</pre>
 +
 +
 +
  .
 +
    .
 +
  .
 +
    .
  
  

Revision as of 22:43, 19 October 2017



OVERVIEW

This wiki article holds Ted's notes on configuring, deploying, backing up and restoring MYSQL database servers and databases.



MYSQL Reset Root Password

mysql> select Host, User, authentication_string from user;
+---------------+------------------+-------------------------------------------+
| Host          | User             | authentication_string                     |
+---------------+------------------+-------------------------------------------+
| localhost     | root             | *7DED8F04F1F0C0639D9631FEFFDA4539EE31DD17 |
| ubuntu-spare-2| root             | *7DED8F04F1F0C0639D9631FEFFDA4539EE31DD17 |
| 127.0.0.1     | root             | *7DED8F04F1F0C0639D9631FEFFDA4539EE31DD17 |
| ::1           | root             | *7DED8F04F1F0C0639D9631FEFFDA4539EE31DD17 |
| localhost     | debian-sys-maint | *E8C7D3BB3A512229A60E85B7A2A23484ED003A94 |
| localhost     | mysql.sys        | *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE |
| localhost     | wikiuser         | *F05B4F375EA1AC92DB6916D2F25E41B5689539FD |
+---------------+------------------+-------------------------------------------+
7 rows in set (0.02 sec)

mysql> update user set authentication_string=PASSWORD("new-root-password-to-mysql") where User='root';
Query OK, 4 rows affected, 1 warning (0.02 sec)
Rows matched: 4  Changed: 4  Warnings: 1

mysql> select Host, User, authentication_string from user;
+---------------+------------------+-------------------------------------------+
| Host          | User             | authentication_string                     |
+---------------+------------------+-------------------------------------------+
| localhost     | root             | *A070565E56DA8DBCF462EEE4A67C59881CC60597 |
| ubuntu-spare-2| root             | *A070565E56DA8DBCF462EEE4A67C59881CC60597 |
| 127.0.0.1     | root             | *A070565E56DA8DBCF462EEE4A67C59881CC60597 |
| ::1           | root             | *A070565E56DA8DBCF462EEE4A67C59881CC60597 |
| localhost     | debian-sys-maint | *E8C7D3BB3A512229A60E85B7A2A23484ED003A94 |
| localhost     | mysql.sys        | *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE |
| localhost     | wikiuser         | *F05B4F375EA1AC92DB6916D2F25E41B5689539FD |
+---------------+------------------+-------------------------------------------+
7 rows in set (0.00 sec)

mysql>


Commands to grant all privileges to a user and to show privileges of a MYSQL user:


user@localhost:~/projects/database-back-ups$ mysql -u root -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 3316
Server version: 5.1.54-1ubuntu4 (Ubuntu)

Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
This software comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to modify and redistribute it under the GPL v2 license

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> grant all privileges on *.* to 'jose'@'localhost' identified by 'database_pass_phrase' with grant option;

mysql> show grants for 'jose'@'localhost';

+---------------------------------------------------------------------------------------------------------------------------------------+
| Grants for jose@localhost                                                                                                              |
+---------------------------------------------------------------------------------------------------------------------------------------+
| GRANT ALL PRIVILEGES ON *.* TO 'jose'@'localhost' IDENTIFIED BY PASSWORD '*0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ0123' WITH GRANT OPTION |
+---------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)


  .
   .
  .
   .


MYSQL Multiple Servers On One Host



References

- 2017-07-xx -

- 2017-07-27 Thursday -