Linux - ServerThis forum is for the discussion of Linux Software used in a server related context.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
for resetting the root user's password. Actually, I am using www.linuxzoo.net for online practice of Linux and have MySQL installed on it. But I forgot the password I set. There was no password by default set for the root user. So, I just trying setting a password last week. Now I am not getting what I did.
Anyways, I did these things:
Code:
-bash-2.05b# cat /root/mysql-init
UPDATE mysql.user SET Password=PASSWORD('root') WHERE User='root';
FLUSH PRIVILEGES;
-bash-2.05b#
Code:
mysqld (pid 3119 3118 3117 3116) is running...
-bash-2.05b# kill `cat /var/run/mysqld/mysqld.pid`
-bash-2.05b# service mysqld status
mysqld dead but subsys locked
Code:
-bash-2.05b# mysqld_safe --init-file=/root/mysql-init
-bash: mysqld_safe: command not found
Code:
-bash-2.05b#
-bash-2.05b# service mysqld --skip-grant-tables restart
Usage: /etc/init.d/mysqld {start|stop|status|condrestart|restart}
-bash-2.05b# service "mysqld --skip-grant-tables" restart
mysqld --skip-grant-tables: unrecognized service
So, mysqld_safe is not working. I am not able to restart mysqld service with the option "--skip-grant-tables" as described in the web page given above.
Distribution: On my PC I use RHEL, at office AIX, Solaris, HP-UX, RHEL.
Posts: 254
Original Poster
Rep:
Quote:
Originally Posted by bathory
You can do the following to start the service with the --skip-grant-tables option:
Code:
service mysqld stop
/usr/sbin/mysqld --skip-grant-tables
After that follow the generic instructions from the page you mentioned:
I tried these steps:
Code:
mysqld (pid 1359 1358 1357 1356) is running...
-bash-2.05b# kill `cat /var/run/mysqld/mysqld.pid`
-bash-2.05b# /usr/sbin/mysqld --skip-grant-tables
-bash: /usr/sbin/mysqld: No such file or directory
The above commands didn't work. So I did this:
Code:
-bash-2.05b# which mysqld
/usr/bin/which: no mysqld in (/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/sb in:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/X11R6/bin:/root/bin:/usr/ke rberos/sbin:/usr/kerberos/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbi n:/usr/bin:/usr/X11R6/bin:/root/man)
-bash-2.05b# /etc/rc.d/init.d/mysqld --skip-grant-tables
Usage: /etc/rc.d/init.d/mysqld {start|stop|status|condrestart|restart}
-bash-2.05b# service mysqld start
Starting MySQL: [ OK ]
-bash-2.05b# service mysqld stop
Stopping MySQL: [ OK ]
-bash-2.05b# /etc/rc.d/init.d/mysqld
Usage: /etc/rc.d/init.d/mysqld {start|stop|status|condrestart|restart}
Code:
-bash-2.05b# /usr/libexec/mysqld --skip-grant-tables
Fatal error: Please read "Security" section of the manual to find out how to run mysqld as root!
100921 23:07:12 Aborting
100921 23:07:12 /usr/libexec/mysqld: Shutdown Complete
-bash-2.05b#
Distribution: On my PC I use RHEL, at office AIX, Solaris, HP-UX, RHEL.
Posts: 254
Original Poster
Rep:
Linux and MySQL Versions
Quote:
Originally Posted by bathory
What distro and mysql version are you running and how did you install myslq?
Code:
-bash-2.05b# uname -a
Linux host-6-7.linuxzoo.net 2.6.18.1 #5 Thu Nov 30 12:51:52 GMT 2006 i686 i686 i386 GNU/Linux
-bash-2.05b# mysqladmin --version
mysqladmin Ver 8.23 Distrib 3.23.58, for redhat-linux-gnu on i386
Code:
-bash-2.05b# cat /etc/issue
Fedora Core release 2 (Tettnang)
Kernel \r on an \m
I didn't install it manually. There is a UML (User Mode Linux) available on www.linuxzoo.net which we can use for our practice purpose. MySQL is installed on it by default. I think I had mistyped the password otherwise I generally remember my passwords and I use which I can remember when doing some testing. But I am curious to troubleshoot it.
Code:
-bash-2.05b# mysql -u root -p
Enter password:
ERROR 1045: Access denied for user: 'root@localhost' (Using password: YES)
Last edited by Hi_This_is_Dev; 09-21-2010 at 05:45 PM.
Distribution: On my PC I use RHEL, at office AIX, Solaris, HP-UX, RHEL.
Posts: 254
Original Poster
Rep:
Code:
-bash-2.05b# service mysqld stop
Stopping MySQL: [ OK ]
-bash-2.05b# /usr/libexec/mysqld --skip-grant-tables -u mysql &
[1] 1775
-bash-2.05b# Cannot initialize InnoDB as 'innodb_data_file_path' is not set.
If you do not want to use transactional InnoDB tables, add a line
skip-innodb
to the [mysqld] section of init parameters in your my.cnf
or my.ini. If you want to use InnoDB tables, add to the [mysqld]
section, for example,
innodb_data_file_path = ibdata1:10M:autoextend
But to get good performance you should adjust for your hardware
the InnoDB startup options listed in section 2 at
http://www.innodb.com/ibman.html
/usr/libexec/mysqld: ready for connections
-bash-2.05b# mysql -u mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1 to server version: 3.23.58
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql> show databases
-> ;
+----------+
| Database |
+----------+
| DevDB |
| mysql |
| test |
+----------+
3 rows in set (0.00 sec)
mysql> quit
Bye
-bash-2.05b# mysql -u mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2 to server version: 3.23.58
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql>
mysql> quit
Bye
-bash-2.05b# mysql -u root
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 3 to server version: 3.23.58
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql>
Distribution: On my PC I use RHEL, at office AIX, Solaris, HP-UX, RHEL.
Posts: 254
Original Poster
Rep:
How can we view all the user names?
I tried this...
Code:
-bash-2.05b# mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 13 to server version: 3.23.58
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql> select user from mysql.user;
+------+
| user |
+------+
| |
| root |
| |
| root |
+------+
4 rows in set (0.00 sec)
mysql>
mysql> quit
Bye
Apparently there is only root user appearing twice but the above output reports "4 rows".
Why?
I am also able to log in using the user name: mysql....
Code:
-bash-2.05b# mysql -u mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 14 to server version: 3.23.58
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql>
So, I am not able to assign a password to this user: mysql...
Apparently there is only root user appearing twice but the above output reports "4 rows".
The 2 blank rows mean that there are also 2 "anonymous" users.
The fact that you can connect using mysql (it's an anonymous account) is because you're running the server with "--skip-grant-tables". You can connect to the database using whatever name you want in this situation.
Distribution: On my PC I use RHEL, at office AIX, Solaris, HP-UX, RHEL.
Posts: 254
Original Poster
Rep:
Quote:
Originally Posted by bathory
The 2 blank rows mean that there are also 2 "anonymous" users.
The fact that you can connect using mysql (it's an anonymous account) is because you're running the server with "--skip-grant-tables". You can connect to the database using whatever name you want in this situation.
Regards
Thanks for the explanation!
Here is my experiment:
Code:
mysql> select user from mysql.user;
+------+
| user |
+------+
| |
| root |
| |
| root |
+------+
4 rows in set (0.00 sec)
mysql> delete from mysql.user where user <> 'root';
Query OK, 2 rows affected (0.00 sec)
mysql> select user from mysql.user;
+------+
| user |
+------+
| root |
| root |
+------+
2 rows in set (0.00 sec)
mysql>
mysql> quit
Bye
Code:
-bash-2.05b# mysql -u mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 7 to server version: 3.23.58
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql> quit
Bye
Code:
-bash-2.05b# mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 8 to server version: 3.23.58
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
mysql> quit
Bye
Code:
-bash-2.05b# mysql -u mysql
ERROR 1045: Access denied for user: 'mysql@localhost' (Using password: NO)
-bash-2.05b#
Code:
-bash-2.05b# mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 10 to server version: 3.23.58
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql> insert into mysql.user (user) values ('');
Query OK, 1 row affected (0.00 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
mysql> quit
Bye
Code:
-bash-2.05b# mysql -u mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 11 to server version: 3.23.58
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql> quit
Bye
-bash-2.05b#
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.