Linux – CentOS 5.8 – The most difficult MySQL installation ever

centoslinuxMySQLsql

To install I did:

yum --enablerepo=remi,remi-test install mysql mysql-server

Result of the last 3 lines:

Installed:
 mysql-server.x86_64 0:5.0.95-5.el5_9

Complete!

Then I did the following:

[root@resdb-1 mysql]# /etc/init.d/mysqld start
Starting mysqld:                                          [  OK  ]

Then I do the following:

[root@resdb-1 mysql]# /usr/bin/mysql_secure_installation




NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MySQL
  SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!


In order to log into MySQL to secure it, we'll need the current
password for the root user.  If you've just installed MySQL, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.

Enter current password for root (enter for none): **(I PRESSED ENTER HERE)**
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)

For the life of me I cannot set a password for root, I've tried everything I found on the web, doing it by using mysqladmin -u root password NEWPASSWORD, I always get the same message each and every time (sometimes it's 'using password: yes'): ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)

I even managed to stop the service, hop into mysql -u root and set using sql command, but it still doesn't work, nothing changes.

What am I doing wrong here?

EDIT:

I tried the following without any luck:

[root@resdb-1 mysqld]# kill `cat /var/run/mysqld/mysqld.pid`
[root@resdb-1 mysqld]# mysqld_safe --init-file=/home/maddock/mysql-init &
[3] 20961
[root@resdb-1 mysqld]# Starting mysqld daemon with databases from /var/lib/mysql
STOPPING server from pid file /var/run/mysqld/mysqld.pid
140129 20:32:00  mysqld ended


[3]-  Done                    mysqld_safe --init-file=/home/maddock/mysql-init
[root@resdb-1 mysqld]# /sbin/service mysqld start
Starting mysqld:                                          [  OK  ]
[root@resdb-1 mysqld]# mysql -u root -p
Enter password:
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
[root@resdb-1 mysqld]#

EDIT 2:

This here contains the command to reset the password: /home/maddock/mysql-init contents:

UPDATE mysql.user SET Password=PASSWORD('testpass') WHERE User='root';
FLUSH PRIVILEGES;

Best Answer

I think @tink had it right from the start.

An uninstall doesn't delete databases; it deletes the database software.

If you've installed MySQL, configured a root password, uninstalled MySQL and finally installed another version of MySQL your data from the first install is still there.

If it wasn't, imagine how surprised you would be when you upgraded the installed MySQL RPM on a production server. An upgrade is essentially an uninstall, then a new install.

If you truly want to start from scratch, you'll need to delete the existing files by hand. They are typically in /var/lib/mysql on Linux.

If you currently have no MySQL data you need to save and your configuration is left at the default location you should be able to fix it by:

rm -rf /var/lib/mysql/*; mysql_install_db.

Related Topic