个人工具

UbuntuHelp:MYSQL5FromSource

来自Ubuntu中文

Oneleaf讨论 | 贡献2007年5月13日 (日) 11:25的版本 (New page: {{From|https://help.ubuntu.com/community/MYSQL5FromSource}} {{Languages|php5}} Please discuss in [http://www.ubuntuforums.org/showthread.php?t=93725&page=1&pp=10 this thread on Ubuntu foru...)

(差异) ←上一版本 | 最后版本 (差异) | 下一版本→ (差异)
跳转至: 导航, 搜索

Please discuss in this thread on Ubuntu forums.

Tested in Breezy. Mysql5.0 is already in Dapper. It is in main. It is installed when you install the default LAMP stack in Dapper.

Prerequisites

You must download MYSQL5 (of course ;)

wget http://dev.mysql.com/get/Downloads/MySQL-5.0/mysql-5.0.16.tar.gz/from/http://mysql.localhost.net.ar/
tar xzvf mysql-5.0.16.tar.gz
cd mysql-5.0.16/
</code>

==== You must install packages : ====
<pre>
sudo apt-get install build-essential
</code>

==== You need development libraries ====
... but I'm not sure about which ones.

<pre>
sudo apt-get install libncurses5 libncurses5-dev
</code>

...or you won't be able to compile on a server install

==== You need to create the user and group ====
<pre>
sudo groupadd mysql
sudo useradd -g mysql mysql
</code>

=== Compilation optimisation ===

You can speed up Mysql with processor optimisation

If you have a different processor, change the CHOST, CFLAGS, CXXFLAGS.

If you don't know what it is, Take the Generic one!

attachment:IconsPage/IconWarning3.png 
The configuration for specific processors were not tested. If it compiles you're fine. If it doesn't try the generic one. Use only one of the following three

* Athlon-tbird XP (AMD)
<pre>
export CHOST="i686-pc-linux-gnu"
export CFLAGS="-march=athlon-xp -O3 -pipe -fomit-frame-pointer -msse -mmmx  -mfpmath=sse"
export CXXFLAGS="-march=athlon-xp -O3 -pipe -fomit-frame-pointer -msse -mmmx  -mfpmath=sse -felide-constructors -fno-exceptions -fno-rtti"
export CXX=gcc 
</code>

* Pentium 4 (Intel)
<pre>
export CHOST="i686-pc-linux-gnu"
export CFLAGS="-march=pentium4 -mcpu=pentium4 -O3 -pipe -fomit-frame-pointer -msse -mmmx  -mfpmath=sse"
export CXXFLAGS="-march=pentium4 -mcpu=pentium4 -O3 -pipe -fomit-frame-pointer -msse -mmmx  -mfpmath=sse -felide-constructors -fno-exceptions -fno-rtti"
export CXX=gcc 
</code>

* Generic
<pre>
export CHOST="i686-pc-linux-gnu"
export CFLAGS="-mcpu=i686 -march=i686 -O3 -pipe -fomit-frame-pointer"
export CXX=gcc 
</code>

<code>-fomit-frame-pointer</code> should be omitted if you intend to debug. Otherwise leave it as it make mysql faster. 

=== Configuration ===
This is a full configuration.

Do it in the MYSQL5 folder.

You can add/delete some of the options if you don't need it.
This is intended to be a default mysql5 installation, again I'm not sure about this.

<pre>
./configure \
--prefix=/usr/local/mysql \
--with-mysqld-user=mysql \
--without-debug \
--with-client-ldflags=-all-static \
--with-mysqld-ldflags=-all-static \
--disable-shared \
--localstatedir=/usr/local/mysql/data \
--with-extra-charsets=none \
--enable-assembler \
--with-unix-socket-path=/tmp/mysql.socket

make
sudo make install
</code>

This will install mysql in <code>/usr/local/mysql</code> and data in <code>/usr/local/mysql/data</code>.


==== my.conf ====
Now create the conf based in any of the pre-build confs. For small servers I recommend my-medium.cnf

<pre>
sudo cp support-files/my-medium.cnf /etc/my.cnf
</code>

You should edit this file for your needs.

==== Create GRANT tables ====
You must create the GRANT tables, and there is a very easy way to do so.
<pre>
sudo /usr/local/mysql/bin/mysql_install_db --user=mysql
</code>

==== Changing Owners ====
<pre>
sudo chown -R root  /usr/local/mysql
sudo chown -R mysql /usr/local/mysql/var
sudo chgrp -R mysql /usr/local/mysql
</code>

=== Testing ===
Start the server
<pre>
/usr/local/mysql/bin/mysqld_safe -user=mysql&
</code>
Set a root password for MySQL (does not affect system root's password)
<pre>
/usr/local/mysql/bin/mysqladmin -u root password new_password
</code>
Try to log in!
<pre>
/usr/local/mysql/bin/mysql
</code>

You should add <code>/usr/local/mysql/bin</code> to your path so you can always use mysql, mysqldump, mysqladmin and some others right from the shell.

=== Starting Mysql at boot time ===

<pre>
sudo cp support-files/mysql.server /etc/init.d/mysql
sudo chmod +x /etc/init.d/mysql
sudo update-rc.d mysql defaults
</code>

When you restart mysql should be up if everything went ok.


=== MySQL Tools ===

* MySQL Administrator. MySQL Administrator is a powerful visual administration tool that makes it easy to administer and monitor your MySQL environment and gain significantly better visibility into how your databases are operating. More information at http://www.mysql.com/products/tools/administrator/ . To use install:
<pre>
mysql-admin
</code>

* phpmyadmin. A tool written in PHP intended to handle the administration of MySQL over the Web. Currently it can create and drop databases, create/drop/alter tables, delete/edit/add fields, execute any SQL statement, manage keys on fields, manage privileges,export data into various formats and is available in 50 languages. More information at http://www.phpmyadmin.net . To use install:
<pre>
phpmyadmin
</code>

CategoryDocumentation CategoryCleanup

[[category:UbuntuHelp]]