I would not recommend doing this. Use synaptic as far as possible, it's way cleaner and faster. In my case, I needed some additional configuration ergo I used source.
1. Step one download the source from the official MySQL downloads page. Pick the community server, and select the MySQL source tarball.
2. I referred to this wiki about how to install MySQL on Ubuntu from source most of the time, but somewhere down the line it failed me. Anyways, on with it. After downloading, extract it using:
tar xzvf mysql-yourversionnumber.tar.gz
3. Before you proceed you need to install three packages. build-essentials, libncurses5 libncurses5-dev. I used synaptic to do this.
4. Now, add a user and group allowing MySQL to run.
sudo groupadd mysql
sudo useradd -g mysql mysql
5. Now, change your directory to the one you just extracted into and use the following options for the configure script.
./configure \
--prefix=/usr/local/mysql \
--with-mysqld-user=mysql \
--without-debug \ (I didn't use this)
--with-client-ldflags=-all-static \
--with-mysqld-ldflags=-all-static \ (In case you want to enable dynamic loading use -rdynamic)
--disable-shared \ (I didn't use this)
--localstatedir=/usr/local/mysql/data \
--with-extra-charsets=none \ (I didn't use this)
--enable-assembler \ (I didn't use this)
--with-unix-socket-path=/tmp/mysql.socket
The options I used are as below, note, I used rdynamic for dynamic loading, so that I can call C functions within MySQL statements. I used the with-embedded-server option so that I can use the lmysqld library which compiles the MySQL C API which allows me to write MySQL code within a C program.
./configure \
--prefix=/usr/local/mysql \
--with-mysqld-user=mysql \
--with-client-ldflags=-rdynamic \
--with-mysqld-ldflags=-rdynamic \
--localstatedir=/usr/local/mysql/data \
--with-unix-socket-path=/tmp/mysql.socket \
--with-embedded-server
6. After this is done.
sudo make
sudo make install
The make took some time on my machine, at this point go read a book :)
7. Okay, now once this is done. What you need to do is setup the config file for MySQL giving it some default paramters for its connections.
sudo cp support-files/my-medium.cnf /etc/my.cnf
This is assuming you're still inside the MySQL-yourversionnumber directory you extracted the downloaded tarball in.
8. Now you've got to create the GRANT tables. This is easy just run a pre-provided script.
sudo /usr/local/mysql/bin/mysql_install_db --user=mysql
9. Now, you need to setup permissions. Here is where I messed up real bad, like took me two days to get it right after four OS re-installs bad.
So, the wiki says you need to do this.
sudo chown -R root /usr/local/mysql
sudo chown -R mysql /usr/local/mysql/var
sudo chgrp -R mysql /usr/local/mysql
Which looks all good, but my install didn't have a /usr/local/mysql/var directory and it erred here, which lead to another error in the next step. That is the step when you setup the MySQL daemon.
Instead, if the code above gives you an error. Go for this. Make sure you change to the directory you installed MySQL in, i.e. /usr/local/mysql/
chown -R root .
chown -R mysql data
chgrp -R mysql .
10. Once that's done. You need to start up the MySQL daemon (process which runs in the background)
/usr/local/mysql/bin/mysqld_safe -user=mysql&
If this doesn't say something bad like STOPPED then you're in the clear.
11. Set a password for the main user.
/usr/local/mysql/bin/mysqladmin -u root password 'new_password'
Login:
/usr/local/mysql/bin/mysql
12. Now, we setup the daemon to start itself automatically when your PC boots up.
sudo cp support-files/mysql.server /etc/init.d/mysql
sudo chmod +x /etc/init.d/mysql
sudo update-rc.d mysql defaults
Again, make sure you're still in the same directory that you extracted all the files in.
And you're done!
"Life goes on, and it's infuriating"
Lordi - It Snows In Hell.
0 Responses to Installing MySQL from source on Xubuntu
Something to say?