LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Server (https://www.linuxquestions.org/questions/linux-server-73/)
-   -   ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES) (https://www.linuxquestions.org/questions/linux-server-73/error-1045-28000-access-denied-for-user-root%40localhost-using-password-yes-900690/)

jsaravana87 09-02-2011 05:07 AM

ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
 
Hi


i had placed % in my mysql configuration scripts but since its not listening localhost
i checked out my vi /etc/my.cnf localhost is enabled

root@localhost Desktop]# mysql -u root
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 42
Server version: 5.0.77 Source distribution

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> \q
Bye
[root@localhost Desktop]# mysql -u root -p
Enter password:
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)


vi /etc/my.cnf

[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
user=mysql
# Default to using old password format for compatibility with mysql 3.x
# clients (those using the mysqlclient10 compatibility package).
old_passwords=1

# Disabling symbolic-links is recommended to prevent assorted security risks;
# to do so, uncomment this line:
# symbolic-links=0

[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid

useradd chatRoot3

mysql1=$(</dev/urandom tr -dc A-Za-z0-9 | head -c6) ; echo $mysql1 ; echo $mysql1 | passwd --stdin chatRoot3

echo 'CREATE DATABASE chat3;' | mysql -uroot -psanjay
echo "CREATE USER 'chatRoot3'@'%' IDENTIFIED BY '$mysql1';" | mysql -uroot -pecare2@

echo "GRANT ALL PRIVILEGES ON *.* TO 'chatRoot3'@'%' IDENTIFIED BY '$mysql1';" | mysql -uroot -psanjay

echo -e "DATABASENAME\ndatabasename=chat3\ndatabaseusername=chatRoot3\npassword=$mysql1\ncustomername=$1 " | mail -s 'MysqlDatabase Access' xxxx@gmail.com

regards
arun

timur91 09-02-2011 07:43 AM

are you sure you set the root password for mysql? I can see you can login without a pass

try this:
Code:

select * from mysql.user where user='root';
See if there's a password for the root user with the % hostname, if not, set it

java socket

raevin 09-02-2011 10:22 AM

Quote:

Originally Posted by timur91 (Post 4459607)
are you sure you set the root password for mysql? I can see you can login without a pass

try this:
Code:

select * from mysql.user where user='root';
See if there's a password for the root user with the % hostname, if not, set it

More importantly is to make sure a password is set. To do that, as it seems there is no password set for root, you can do it by running this command inside the MySQL prompt:
Code:

GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'root_password_goes_here';


All times are GMT -5. The time now is 12:01 AM.