Sunday, January 17, 2010

Install MySQL on Ubuntu 9.10 (Karmic Koala)

On Ubuntu 9.10 you can install MySQL using :
  1. Ubuntu Software Center, search for MySQL server and install it;
  2. Synaptic Package Manager, search for MySQL and install MySQL-server package with the dependencies, MySQL-client , the libraries and other packages you would need;
  3. Terminal, here you have to write the command(s) needed to install MySQL server;
If you choose the first two options the installation will be done automatically but you will have to set up a password after the installation is completed.
root/anonymous Password Assignment
shell> mysql -u root
mysql> SET PASSWORD FOR 'root'@'localhost' = 
PASSWORD('newpwd');
mysql> SET PASSWORD FOR 'root'@'host_name' = 
PASSWORD('newpwd');
Replace host_name with the name of the server host:
mysql> SET PASSWORD FOR'root'@'127.0.0.1' = 
PASSWORD('newpwd'); 
To assign passwords to the root accounts using mysqladmin
execute the following commands:
shell> mysqladmin -u root password "newpwd"
shell> mysqladmin -u root -h host_name password "newpwd"
Is there a default MySQL password? According to the MySQL documentation if you didn't set up a password, the initial password when connecting to the server is blank.

It is possible when connecting for the first time to the server, using the blank password or when trying to set up a root password to get the following error:
ERROR 1045 : Access denied for user 'root'@'localhost' (using password: NO)

If you don't have enough time to go back and forth to see what went wrong and how would you fix it, the best solution at this point is to remove your MySQL server and try the third option, use the Terminal to (re)install MySQL server.
This is the simplest, the fastest way to install MySQL server on Ubuntu 9.10:
  1. Open a Terminal and execute the following command; you must have sudo privilege if you are a standard user to execute this command:


    sudo apt-get install mysql-server

     












2. The installation will begin and you'll be prompted to set a password for the root user. Don't leave your password blank , choose a strong password and better do not forget it.    
3. The MySQL server package is now installed , along with dependencies and client libraries and you can connect to the server executing this command in the terminal:
 mysql -u root -p yourpassword
 If you are using MySQL Administrator/similar tool you must fill 
in: Server HostName (127.0.0.1),Port (3306),Username (root) 
and Password (your password) to connect.

No comments: