Skip to content

Instantly share code, notes, and snippets.

@beaudierman
Created April 23, 2013 16:11
Show Gist options
  • Star 6 You must be signed in to star a gist
  • Fork 5 You must be signed in to fork a gist
  • Save beaudierman/5444977 to your computer and use it in GitHub Desktop.
Save beaudierman/5444977 to your computer and use it in GitHub Desktop.
How to install MySQL 5.6 on Ubuntu 12.04
I recently had to install MySQL 5.6 on Ubuntu 12.04 from a .deb package on the MySQL website. It seems that either the package has been updated recently or nobody uses this method to install so I ended up running into endless problems. Through trial and error I found the following method works for me.
Install libaio-dev:
sudo apt-get install libaio-dev
Now install your package(mine was enterprise edition, community may have a different filename):
sudo dpkg -i mysql-advanced-5.6.10-debian6.0-x86_64.deb
This will install your files to the /opt directory, instead of the more common /etc directory. No worries, all we need to do is point our system at this new directory.
Run the following commands to set up the mysql user and group if you have never had mysql installed before. If you had a previous version installed, the user and group are already created.
sudo groupadd mysql
sudo useradd -r -g mysql mysql
Move into the mysql directory and make a data directory.
cd /top/mysql/server-5.6/
sudo mkdir data
sudo chown mysql:mysql data
Now we can create and configure the database.
sudo scripts/mysql_install_db --user=mysql --language=/opt/mysql/server-5.6/share/english/
sudo cp support-files/my-default.cnf /etc/my.cnf
sudo cp support-files/mysql.server /etc/init.d/mysql.server
sudo cp support-files/mysql-log-rotate /etc/logrotate.d/mysql.server
Before we start the server, let's make sure MySQL is only going to be using the one configuration file.
sudo rm /etc/mysql/my.cnf /opt/mysql/server-5.6/my.cnf
Now let's start MySQL server.
sudo service mysql.server start
All that's left is to set your PATH so that mysql is accessible from any location.
echo 'export PATH=$PATH:/opt/mysql/server-5.6/bin' | sudo tee /etc/profile.d/mysql.server.sh
From this point you'll be able to log in to MySQL locally with any username you can think of - or no username at all.
mysql -u anyusernameintheworld
That's obviously very bad practice. Let's go ahead and add a password to the root useraccount and then create a username that we'll actually query with.
mysql
UPDATE mysql.user SET Password=PASSWORD('yournewpassword') WHERE User='root';
FLUSH PRIVILEGES;
GRANT ALL ON *.* TO 'newuser'@'localhost' IDENTIFIED BY 'newuserpassword';
FLUSH PRIVILEGES;
And if you'd like the new user to be able to connect from outside host machines.
GRANT ALL ON *.* TO 'newuser'@'%' IDENTIFIED BY 'newuserpassword';
FLUSH PRIVILEGES;
Please note that you can(and should) change % to be an IP address that you are connecting from. The % is a wildcare operator, so if you'd like everyone on your local network to connect you could use something like 192.168.%.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment