Learning Mysql


--user=your_mysql_username \



Download 4.24 Mb.
View original pdf
Page300/366
Date04.08.2023
Size4.24 Mb.
#61806
1   ...   296   297   298   299   300   301   302   303   ...   366
Learning MySQL
--user=your_mysql_username \
--password=your_old_mysql_password \
password "your new mysql password"
326 | Chapter 9:
Managing Users and Privileges

Notice that since the new password contains spaces, we’ve enclosed it in quotes.
The user and host options are for the user you want to connect as and the server you want to connect to, respectively. You can use mysqladmin to change the password for only your own username on localhost
. For example, if your MySQL username is sarah
, you can change the password only for 'sarah'@'localhost'
. Or if you want to change the password for another username and host pair, such as 'sarah'@'sadri.invy home.com or 'susan'@'localhost'
, you’ll need to use the MySQL monitor or another more flexible MySQL client.
If you’re running MySQL for the first time, or if your MySQL user doesn’t have a password already set, you don’t need to specify the current password—that is, you can omit the password option.
You can also remove a user’s password. Here’s an example using the SET PASSWORD
statement:
mysql> SET PASSWORD FOR 'selina'@'localhost' = '';
Query OK, 0 rows affected (0.00 sec)
This stores the empty string as the password, allowing connections without a password parameter. Again, it’s important to always use passwords for any production server.
Sometimes, you’ll want to create anew user with the same password as another, or you’ll want to recreate or migrate users from one installation to another. In these cases,
you may not know the plain-text password of all users, but if you have access to the
SHOW GRANTS
statement or the mysql database, you can discover the hashed values. If you want to create a user using a hashed password instead of asking MySQL to hash the password for you, use the
PASSWORD
keyword as follows:
mysql> GRANT USAGE ONTO 'partmusic'@'localhost'

Download 4.24 Mb.

Share with your friends:
1   ...   296   297   298   299   300   301   302   303   ...   366




The database is protected by copyright ©ininet.org 2024
send message

    Main page