If you're new here, you may want to subscribe to my RSS feed. Thanks for visiting!
Installing Mysql database in Ubuntu
#apt-get install mysql-server mysql-client libmysqlclient12-dev
MySQL initially only allows connections from the localhost (127.0.0.1). We’ll need to remove that restriction if you wish to make it accessible to everyone on the internet. Open the file /etc/mysql/my.cnf
#vi /etc/mysql/my.cnf
Find the line bind-address = 127.0.0.1 and comment it out
…
#bind-address = 127.0.0.1
…
You can check your configuration using the following command
#netstat -tap
Output Looks like below
tcp 0 0 *:mysql *:* LISTEN 4997/mysqld
MySQL comes with no root password as default. This is a huge security risk. You’ll need to set one. So that the local computer gets root access as well, you’ll need to set a password for that too. The local-machine-name is the name of the computer you’re working on. For more information see here
#mysqladmin -u root password your-new-password
#mysqladmin -h root@local-machine-name -u root -p password your-new-password
#/etc/init.d/mysql restart
If you are looking how to create database,tables and other things check here
If you are looking for webinterface administration or GUI tools for your mysql database check here
You may also be interested in...
November 6th, 2006 at 1:20 pm
Hi!
I have installed mysql server on my Ubuntu Desktop; and works fine, but I want to change de mysql datadir. Do yo know how can I change that? If I edit my.conf the line datadir for my directori, mysql never restarts.
The new datadir is with the same permissions, and content.
Any ideas? Wy in apache is easy to change but in mysql not?
November 6th, 2006 at 1:51 pm
Hi Lois,
Here is the procedure how to change Mysql default data directory
By default, MySQL’s datadir is placed in the /var/lib/mysql directory.
Create the directory that will be new datadir (ex:-/home/db)
chown the directory to the mysql:mysql user
sudo chown -R mysql:mysql /home/db/*
You need to stop the mysql server using the following command
sudo /etc/init.d/mysql stop
Now you need to edit the /etc/mysql/my.cnf file
sudo vi /etc/mysql/my.cnf
and look for “datadir = /var/lib/mysql” this si where mysql database default data directory here you need to change this one to your new directory
datadir = /home/db
copy the files from the old datadir to the new location. However, make sure that the files named
ib_arch_log_0000000000, ib_logfile0 etc. are not copied to the newer location.
Make sure that the files and directories are owned by mysql user
Make changes in the my.cnf to point the new datadir.
Restart the MySQL database
sudo /etc/init.d/mysql start
hope this helps
November 6th, 2006 at 9:29 pm
Yeah!!! you’re my hero! my problem was the direcotri privilegies in the new datadir; but that’s it with the chown -R mysql:mysql.
Do it after copying the files.
Thanks for all!
April 10th, 2007 at 12:36 pm
why can not I use
sudo /etc/mysql/my.cnf
and I have /etc/my.cnf
so I used
sudo /etc/my.cnf
it said command not found
I did not find “datadir = /var/lib/mysql” in the file my.cnf either.
I want to change the directory of the database, because not enough disk space left.
anybody knows , Please help me, Thanks a lot.
April 10th, 2007 at 3:14 pm
you need to make sure you have vi editor installed in your machine otherwise install vi using the following command
#apt-get install vim
Now you need to edit the file using the following command
sudo vi /etc/mysql/my.cnf
If you install mysql in debian or ubuntu from packages you will find the above file without any problem.
Please give us which operating system you are running and how did you installed mysql server in your machine.
July 12th, 2008 at 6:32 pm
Since apparmor is now standard in ubuntu (at least since hardy, which is the release I’m working with now) you will also have to make a change to /etc/apparmor/apparmor.d/usr.sbin.mysqld as well in order to change the datadir. I needed to add the lines
/home/mysql/ r,
/home/mysql/** rwk,
to enable the correct access permissions to the new data directory.