Wednesday 27 June 2012

Issue:- ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)

Issue:- ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)

Solution:- Follow the below steps.

[root@server ~]# /etc/init.d/mysql stop

Stopping MySQL: [ OK ]

[root@servert1 ~]# mysqld_safe --skip-grant-tables &

[root@servert1 ~]# Starting mysqld daemon with databases from /var/lib/mysql



[root@servert1 ~]# mysql -u root

Welcome to the MySQL monitor. Commands end with ; or \g.

Your MySQL connection id is 1

Server version: 5.0.77 Source distribution

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


mysql> show databases;

+--------------------+

| Database |

+--------------------+

| mysql | 

+--------------------+

1 rows in set (0.13 sec)



mysql> use mysql; 

Reading table information for completion of table and column names

You can turn off this feature to get a quicker startup with -A



Database changed

mysql> show tables;

+---------------------------+

| Tables_in_mysql |

+---------------------------+

| columns_priv | 

| db | 

| func | 

| help_category | 

| help_keyword | 

| help_relation | 

| help_topic | 

| host | 

| proc | 

| procs_priv | 

| tables_priv | 

| time_zone | 

| time_zone_leap_second | 

| time_zone_name | 

| time_zone_transition | 

| time_zone_transition_type | 

| user | 

+---------------------------+

17 rows in set (0.00 sec)



mysql> update user set password=PASSWORD("testpass") where User='root';

Query OK, 3 rows affected (0.05 sec)

Rows matched: 3 Changed: 3 Warnings: 0



mysql> flush privileges; 

Query OK, 0 rows affected (0.04 sec)



mysql> quit



[root@server ~]# /etc/init.d/mysql restart

STOPPING server from pid file /var/run/mysqld/mysqld.pid

101120 04:17:15 mysqld ended

Stopping MySQL: [ OK ]

Starting MySQL: [ OK ]

[1]+ Done mysqld_safe --skip-grant-tables

[root@servert1 ~]# mysql -u root -p

Enter password: 

Welcome to the MySQL monitor. Commands end with ; or \g.

Your MySQL connection id is 2

Server version: 5.0.77 Source distribution



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



mysql>

 

skip column names from mysql select query result

Using the "--skip-column-names" option will remove the column header from the mysql select query results.


Usage: mysql --skip-column-names -u username ....