Quote:<blockquote data-ipsquote="" class="ipsQuote" data-ipsquote-contentcommentid="15102" data-ipsquote-username="Dungeon-Dave" data-cite="Dungeon-Dave" data-ipsquote-timestamp="1315748409" data-ipsquote-contentapp="forums" data-ipsquote-contenttype="forums" data-ipsquote-contentid="4150" data-ipsquote-contentclass="forums_Topic"><div>
<blockquote data-ipsquote="" class="ipsQuote" data-ipsquote-contentcommentid="15092" data-ipsquote-username="feedmebits" data-cite="feedmebits" data-ipsquote-timestamp="1315549052" data-ipsquote-contentapp="forums" data-ipsquote-contenttype="forums" data-ipsquote-contentid="4150" data-ipsquote-contentclass="forums_Topic"><div>
mysql> USE databasename_db;
Database changed
mysql> UPDATE user SET Password=PASSWORD('password') WHERE user='testuser';
ERROR 1146 (42S02): Table 'databasename_db.user' doesn't exist
mysql>
All users are stored in the
mysql.users table, ie: the "users" table in the "mysql" database.
A safer method is to use the "set password" statement, rather than try to update the mysql.users table directly, i.e.:
Code:
set password for testuser = password('PA55W0RD!');
</div></blockquote>
I tried that and I still get an error that user doesn't exist: mysql> set password for testuser = password('password');
ERROR 1133 (42000): Can't find any matching row in the user table
This is what I used to create table and make a user:
Creating new MySQL User:
mysql > create database test_db;
mysql >GRANT ALL PRIVILEGES ON test_db.* TO 'testuser'@'localhost' IDENTIFIED BY 'testuser' WITH GRANT OPTION;
mysql> UPDATE user SET Password=PASSWORD('newpassword') WHERE user='testuser';
The last bit is wrong - don't use "update user" to change the password directly.
Code:
[(none)] mysql> create database test_db;
Query OK, 1 row affected (0.02 sec)
[(none)] mysql> GRANT ALL PRIVILEGES
ON test_db.*
TO 'testuser'@'localhost'
IDENTIFIED BY 'testuser'
WITH GRANT OPTION;
Query OK, 0 rows affected (0.04 sec)
[(none)] mysql> set password for 'testuser'@'localhost' = password('PA55W0RD!');
Query OK, 0 rows affected (0.00 sec)
To test:
Code:
user@neptune:~$ mysql -u testuser --password=PA55W0RD!
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 451
Server version: 5.1.49-1ubuntu8.1 (Ubuntu)
[(none)] mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| test_db |
+--------------------+
2 rows in set (0.00 sec)
[(none)] mysql> use test_db;
Database changed
[test_db] mysql> status
--------------
mysql Ver 14.14 Distrib 5.1.49, for debian-linux-gnu (x86_64) using readline 6.1
Connection id: 451
Current database: test_db
Current user: testuser@localhost
SSL: Not in use
Current pager: stdout
Using outfile: ''
Using delimiter: ;
Server version: 5.1.49-1ubuntu8.1 (Ubuntu)
The alternative is to set the pass during the user creation/grant:
Code:
[(none)] mysql> GRANT ALL PRIVILEGES
ON test_db.*
TO 'testuser'@'localhost'
IDENTIFIED BY 'PA55W0RD!'
WITH GRANT OPTION;
Query OK, 0 rows affected (0.04 sec)
</div></blockquote>