Sunday, December 1, 2013

Install mysql in Linux

1. Download the Mysql package from :
mysql>downloads>MySQL Cluster Community Edition
Linux - Generic (glibc 2.5) (x86, 64-bit), Compressed TAR Archive (292mb))

2. Extract the downloaded archive to some folder and remember the path

3.Open terminal and move to extracted path and execute below command

[root@localhost mysql]# rpm -ivh MySQL-*.rpm

Preparing...                ########################################### [100%]
   1:MySQL-client           ########################################### [ 14%]
   2:MySQL-devel            ########################################### [ 29%]
   3:MySQL-embedded         ########################################### [ 43%]
   4:MySQL-shared-compat    ########################################### [ 57%]
   5:MySQL-shared           ########################################### [ 71%]
   6:MySQL-server           ########################################### [ 86%]
   7:MySQL-test             ########################################### [100%]
completed

4.Now start the mysql service
/etc/init.d/mysqld start    or
/etc/init.d/mysql start

5.(you might got this error)
[root@localhost ~]# mysql -u root
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)

[root@localhost ~]# /usr/bin/mysqladmin -u root -p password 'somepassword'
Enter password:
/usr/bin/mysqladmin: connect to server at 'localhost' failed
error: 'Access denied for user 'root'@'localhost' (using password: YES)'


How to resolve above error
(Execute below commands one by one)
#/etc/init.d/mysql stop
Shutting down MySQL.. SUCCESS!
    #mysqld_safe --skip-grant-tables &;
    #mysql -u root
    mysql> use mysql;
    mysql> update user set password=PASSWORD("newPassword") where User='root';
    mysql> flush privileges;
    mysql> quit
    /etc/init.d/mysqld stop [or     /etc/init.d/mysql stop]
    /etc/init.d/mysqld start [or    /etc/init.d/mysql start]


6. you may also got this error
mysql> use test
ERROR 1820 (HY000): You must SET PASSWORD before executing this statement
mysql>

[SOLUTION]

mysql> SET PASSWORD = PASSWORD('new_password');
Query OK, 0 rows affected (0.00 sec)

No comments:

Post a Comment

web stats