Subscribe to How-To Geek

Recommended: Click Here to Run a Free Scan for Common PC Errors   [Sponsored Link]

Install MySQL Server 5 on Ubuntu

Installing MySQL 5 Server on Ubuntu is a quick and easy process. It almost feels like it should be more difficult.

Open a terminal window, and use the following command:

sudo apt-get install mysql-server

If you are running PHP you will also need to install the php module for mysql 5:

sudo apt-get install php5-mysql

To create a new database, use the mysqladmin command:

mysqladmin create <databasename>

See, really easy!

The Geek is the founder of How-To Geek and a geek enthusiast. When he's not coming up with great how-to articles, he's probably writing at his personal blog. This article was written on 12/28/06 and tagged with: Ubuntu, Adding Software, MySQL

Comments (12)

  1. miyaka

    mysqladmin: connect to server at 'localhost' failed
    error: 'Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)'
    Check that mysqld is running and that the socket: '/var/run/mysqld/mysqld.sock' exists!

  2. Tom

    The last step posted above does not work:

    Here is the output:
    honey@honey:~$ mysqladmin create test
    mysqladmin: connect to server at 'localhost' failed
    error: 'Access denied for user 'honey'@'localhost' (using password: NO)'

  3. iskall

    This tutorial is great except like all the others trying to follow this tutorial gets the same exception/errors, this means you have forgotten some steps, how to start the server. Please update this tutorial and correct it.

  4. Ray Ojinaga

    The command for installing mysql-server-5.0 seems to work, but your instructions are lacking detail. For example, how do you start and stop the server and client? Furthermore, are environment variables required? Most computer users don't want to hack and fuss with their machines for all eternity. I realize that a complete tutorial on mysql is out of the question. However, enough information should be provided so that mysql can be installed, configured, and tested. Additionally, you should provide instructions for those users that download the mysql archive directly to their desktop and wish to install it from their.

  5. OJ

    Start your MySQL server by using the command:
    /etc/rc.d/init.d/mysql start

    you can also stop it via the command:
    /etc/rc.d/init.d/mysql stop

    Surprisingly enough, a Google search for "mysql start" returned this in the first couple of results.

  6. Octavius

    Previous example for Mysql start-stop don't work for me. I using Ubuntu 7.10.
    Good example for me is:

    Start MySQL server by using the command:
    sudo /etc/init.d/mysql start

    Stop MySQL server by using the command:
    sudo /etc/init.d/mysql stop

    Sorry for my english…

  7. Mouse

    A google search does indeed tell me that I should use the command:
    /etc/rc.d/init.d/mysql start

    However, as a newcomer to both MySQL and Ubuntu/Linux this doesn't help me - I simply get the new error "bash: /etc/rc.d/init.d/mysql: No such file or directory". Googling that error doesn't help either; the top results seem to be people who have managed to edit their conf files and have made their installation *stop* working; I haven't yet got as far as making it work in the first place.

    I have installed the MySQL client and server through Synaptic, but haven't yet managed to work out how to start the server. I'm afraid I have to agree with the previous comments on this article - there simply isn't enough information to enable a newbie to work out how to begin. If you're not a newbie, you probably don't need this article at all. More details here would be wonderful!

    (And comments like "see, really easy!" don't help newbies' frustration levels - I know that what I want to do is simple; I know the rest of the world finds it easy; but knowing that it's simple doesn't help me work out what on earth it is I need to type/edit/install/mess about with to make this work).

  8. Fernando Las

    i try this
    sudo apt-get install mysql-server
    but dont work
    NOT FOUND

  9. Conor Kirkpatrick

    When I do this I get this error:

    conorkirk@Conor-WebServer:~$ sudo mysqladmin create conor_data
    mysqladmin: connect to server at 'localhost' failed
    error: 'Access denied for user 'root'@'localhost' (using password: NO)'
    conorkirk@Conor-WebServer:~$

    The tutorial didn't say how to set up Mysql users. :(

  10. keshet

    apt-get worked fine for me. Just pick a password for root.

    Startup & shutdown: System Menu -> Administration -> Services
    You control mysql from here.

    You can do 'ps ax | grep mysql' in a terminal window to see if it is running (you should see /usr/sbin/mysqld running).

    Install MySQL Administrator from Add/Remove to create & manage databases with a nice GUI.

  11. Casey Wise

    Very helpful. I'm working in Ubuntu 8.04 and it went well for me. Thanks for the tutorial!

  12. Gareth Evans

    mysqladmin -u root -p create

    and enter the root paaword you set in the installation of mysql


Leave a Comment




Leave your friendly comment here. If you have a computer help question, leave it on the forums instead.

Note: Your comment may not show up immediately on the site.

Copyright © 2006-2008 HowToGeek.com. All Rights Reserved.