Original mysql authorization error

I tried several ways to install mySql and then access the database on a new installation. OS is RHEL 7. Package used: mysql-5.7.7-0.3.rc.el7.x86_64.rpm-bundle.tar

installation process: 
[root@host1 mysql]# rpm -ivh mysql-community-common-5.7.7-0.3.rc.el7.x86_64.rpm mysql-community-libs-5.7.7-0.3.rc.el7.x86_64.rpm mysql-community-client-5.7.7-0.3.rc.el7.x86_64.rpm mysql-community-server-5.7.7-0.3.rc.el7.x86_64.rpm
 Preparing...                          ################################# [100%]
 Updating / installing...
1:mysql-community-common-5.7.7-0.3.################################# [ 25%]
2:mysql-community-libs-5.7.7-0.3.rc################################# [ 50%]
3:mysql-community-client-5.7.7-0.3.################################# [ 75%]
4:mysql-community-server-5.7.7-0.3.################################# [100%]

then i start the server

 systemctl start mysqld

After that, I try to access the server without a password for root. I get an error like:

[root@host1 mysql]# mysql -u root -p
Enter password:
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)

Since I did not set a single password, I am not very sure why this error occurs. After that, I tried various options, and Mont could help me.

option 1: asks to make a file and change the password using the initialization file. I tried using this and got output like:

    [root@host1 mysql]# mysqld_safe --init-file=/home/me/mysql-init & [1]28469
    -bash: mysqld_safe: command not found

Option 2: set the password using the mysqladmin command

[root@host1 mysql]# /usr/bin/mysqladmin -u root password
mysqladmin: connect to server at 'localhost' failed
error: 'Access denied for user 'root'@'localhost' (using password: NO)'

Option 3: using mysql_secure_installation

[root@host1 mysql]#  mysql_secure_installation

Securing the MySQL server deployment.

Enter password for root user:
Error: Access denied for user 'root'@'localhost' (using password: NO)

Option 4: mysql -u root

[root@host1 mysql]# mysql -u root
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)

. , .

+4
4

, - :

  • MySql

  • onetime.sql, - :

set password for 'root'@'localhost' = PASSWORD('password789');

, , , /home/jason

  1. MySql --init-file:

mysqld_safe --init-file=/home/jason/onetime.sql &

  1. , . .

  2. ... rm /home/jason/onetime.sql

  3. MySql

  4. MySql

:

MySQL ,

/etc/my.cnf,

skip-grant-tables 

MySQL root.

mysql -u root

:

mysql>

:

mysql> use mysql;
mysql> UPDATE user SET password=PASSWORD("YOUR NEW PASSWORD HERE") WHERE User='root';
mysql> flush privileges;
mysql> quit

MySQL:

mysqld stop

/etc/my.cnf, "skip-grant-tables".

MySQL .

mysqld restart

mysql -u root -p

+5

"MySQL v 5.7 mysql,

/var/log/mysqld.log

MySQL Yum CentOS 6/7. , :

cat /var/log/mysqld.log |grep "temporary password"
+6

:

cat /var/log/mysqld.log |grep "temporary password"

[] root @localhost: dI & 2- & FteI8a

sudo mysql_secure_installation
Securing the MySQL server deployment. Enter password for user root: > type here temporary password
The existing password for the user account root has expired. Please set a new password.
New password: > type here your new password  
Re-enter new password:

.pss

+2
source

For those who receive an error that the column password does not exist, follow these steps:

mysql> use mysql;
mysql> UPDATE user SET authentication_string=PASSWORD("YOUR NEW PASSWORD HERE") WHERE User='root';
mysql> flush privileges;
mysql> quit
0
source

All Articles