个人工具

“UbuntuHelp:MYSQL5FromSource”的版本间的差异

来自Ubuntu中文

跳转至: 导航, 搜索
(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...)
 
 
(未显示2个用户的9个中间版本)
第1行: 第1行:
 
{{From|https://help.ubuntu.com/community/MYSQL5FromSource}}
 
{{From|https://help.ubuntu.com/community/MYSQL5FromSource}}
{{Languages|php5}}
+
{{Languages|UbuntuHelp:MYSQL5FromSource}}
 +
'''Please do not make any edits to this article.  Its contents are currently under review and being merged with the ''Ubuntu Server Guide''.  To find the Ubuntu Server Guide related to your specific version, please go to:'''
 +
'''https://help.ubuntu.com/ and click on ''Ubuntu Server Guide'''''
 +
{|border="1" cellspacing="0"
 +
| '''While quite old, this content may still be useful while MySQL is still at version 5.'''
 +
|}
 
Please discuss in [http://www.ubuntuforums.org/showthread.php?t=93725&page=1&pp=10 this thread on Ubuntu forums].
 
Please discuss in [http://www.ubuntuforums.org/showthread.php?t=93725&page=1&pp=10 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.
 
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 ===
 
=== Prerequisites ===
 
 
==== You must download MYSQL5 (of course ;) ====
 
==== You must download MYSQL5 (of course ;) ====
 
<pre><nowiki>
 
<pre><nowiki>
第12行: 第14行:
 
tar xzvf mysql-5.0.16.tar.gz
 
tar xzvf mysql-5.0.16.tar.gz
 
cd mysql-5.0.16/
 
cd mysql-5.0.16/
</nowiki></code>
+
</nowiki></pre>
 
+
 
==== You must install packages : ====
 
==== You must install packages : ====
 
<pre><nowiki>
 
<pre><nowiki>
 
sudo apt-get install build-essential
 
sudo apt-get install build-essential
</nowiki></code>
+
</nowiki></pre>
 
+
 
==== You need development libraries ====
 
==== You need development libraries ====
 
... but I'm not sure about which ones.
 
... but I'm not sure about which ones.
 
 
<pre><nowiki>
 
<pre><nowiki>
 
sudo apt-get install libncurses5 libncurses5-dev
 
sudo apt-get install libncurses5 libncurses5-dev
</nowiki></code>
+
</nowiki></pre>
 
+
 
...or you won't be able to compile on a server install
 
...or you won't be able to compile on a server install
 
 
==== You need to create the user and group ====
 
==== You need to create the user and group ====
 
<pre><nowiki>
 
<pre><nowiki>
 
sudo groupadd mysql
 
sudo groupadd mysql
 
sudo useradd -g mysql mysql
 
sudo useradd -g mysql mysql
</nowiki></code>
+
</nowiki></pre>
 
+
 
=== Compilation optimisation ===
 
=== Compilation optimisation ===
 
 
You can speed up Mysql with processor optimisation
 
You can speed up Mysql with processor optimisation
 
 
If you have a different processor, change the CHOST, CFLAGS, CXXFLAGS.
 
If you have a different processor, change the CHOST, CFLAGS, CXXFLAGS.
 
 
If you don't know what it is, Take the Generic one!
 
If you don't know what it is, Take the Generic one!
 
+
https://help.ubuntu.com/community/IconsPage?action=AttachFile&do=get&target=IconWarning3.png  
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
 
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)
 
* Athlon-tbird XP (AMD)
 
<pre><nowiki>
 
<pre><nowiki>
第51行: 第42行:
 
export CXXFLAGS="-march=athlon-xp -O3 -pipe -fomit-frame-pointer -msse -mmmx  -mfpmath=sse -felide-constructors -fno-exceptions -fno-rtti"
 
export CXXFLAGS="-march=athlon-xp -O3 -pipe -fomit-frame-pointer -msse -mmmx  -mfpmath=sse -felide-constructors -fno-exceptions -fno-rtti"
 
export CXX=gcc  
 
export CXX=gcc  
</nowiki></code>
+
</nowiki></pre>
 
+
 
* Pentium 4 (Intel)
 
* Pentium 4 (Intel)
 
<pre><nowiki>
 
<pre><nowiki>
第59行: 第49行:
 
export CXXFLAGS="-march=pentium4 -mcpu=pentium4 -O3 -pipe -fomit-frame-pointer -msse -mmmx  -mfpmath=sse -felide-constructors -fno-exceptions -fno-rtti"
 
export CXXFLAGS="-march=pentium4 -mcpu=pentium4 -O3 -pipe -fomit-frame-pointer -msse -mmmx  -mfpmath=sse -felide-constructors -fno-exceptions -fno-rtti"
 
export CXX=gcc  
 
export CXX=gcc  
</nowiki></code>
+
</nowiki></pre>
 
+
 
* Generic
 
* Generic
 
<pre><nowiki>
 
<pre><nowiki>
第66行: 第55行:
 
export CFLAGS="-mcpu=i686 -march=i686 -O3 -pipe -fomit-frame-pointer"
 
export CFLAGS="-mcpu=i686 -march=i686 -O3 -pipe -fomit-frame-pointer"
 
export CXX=gcc  
 
export CXX=gcc  
</nowiki></code>
+
</nowiki></pre>
 
+
 
<code><nowiki>-fomit-frame-pointer</nowiki></code> should be omitted if you intend to debug. Otherwise leave it as it make mysql faster.  
 
<code><nowiki>-fomit-frame-pointer</nowiki></code> should be omitted if you intend to debug. Otherwise leave it as it make mysql faster.  
 
 
=== Configuration ===
 
=== Configuration ===
 
This is a full configuration.
 
This is a full configuration.
 
 
Do it in the MYSQL5 folder.
 
Do it in the MYSQL5 folder.
 
 
You can add/delete some of the options if you don't need it.
 
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.
 
This is intended to be a default mysql5 installation, again I'm not sure about this.
 
 
<pre><nowiki>
 
<pre><nowiki>
 
./configure \
 
./configure \
第93行: 第77行:
 
make
 
make
 
sudo make install
 
sudo make install
</nowiki></code>
+
</nowiki></pre>
 
+
 
This will install mysql in <code><nowiki>/usr/local/mysql</nowiki></code> and data in <code><nowiki>/usr/local/mysql/data</nowiki></code>.
 
This will install mysql in <code><nowiki>/usr/local/mysql</nowiki></code> and data in <code><nowiki>/usr/local/mysql/data</nowiki></code>.
 
 
 
==== my.conf ====
 
==== my.conf ====
 
Now create the conf based in any of the pre-build confs. For small servers I recommend my-medium.cnf
 
Now create the conf based in any of the pre-build confs. For small servers I recommend my-medium.cnf
 
 
<pre><nowiki>
 
<pre><nowiki>
 
sudo cp support-files/my-medium.cnf /etc/my.cnf
 
sudo cp support-files/my-medium.cnf /etc/my.cnf
</nowiki></code>
+
</nowiki></pre>
 
+
 
You should edit this file for your needs.
 
You should edit this file for your needs.
 
 
==== Create GRANT tables ====
 
==== Create GRANT tables ====
 
You must create the GRANT tables, and there is a very easy way to do so.
 
You must create the GRANT tables, and there is a very easy way to do so.
 
<pre><nowiki>
 
<pre><nowiki>
 
sudo /usr/local/mysql/bin/mysql_install_db --user=mysql
 
sudo /usr/local/mysql/bin/mysql_install_db --user=mysql
</nowiki></code>
+
</nowiki></pre>
 
+
 
==== Changing Owners ====
 
==== Changing Owners ====
 
<pre><nowiki>
 
<pre><nowiki>
第118行: 第95行:
 
sudo chown -R mysql /usr/local/mysql/var
 
sudo chown -R mysql /usr/local/mysql/var
 
sudo chgrp -R mysql /usr/local/mysql
 
sudo chgrp -R mysql /usr/local/mysql
</nowiki></code>
+
</nowiki></pre>
 
+
 
=== Testing ===
 
=== Testing ===
 
Start the server
 
Start the server
 
<pre><nowiki>
 
<pre><nowiki>
 
/usr/local/mysql/bin/mysqld_safe -user=mysql&
 
/usr/local/mysql/bin/mysqld_safe -user=mysql&
</nowiki></code>
+
</nowiki></pre>
 
Set a root password for MySQL (does not affect system root's password)
 
Set a root password for MySQL (does not affect system root's password)
 
<pre><nowiki>
 
<pre><nowiki>
 
/usr/local/mysql/bin/mysqladmin -u root password new_password
 
/usr/local/mysql/bin/mysqladmin -u root password new_password
</nowiki></code>
+
</nowiki></pre>
 
Try to log in!
 
Try to log in!
 
<pre><nowiki>
 
<pre><nowiki>
 
/usr/local/mysql/bin/mysql
 
/usr/local/mysql/bin/mysql
</nowiki></code>
+
</nowiki></pre>
 
+
 
You should add <code><nowiki>/usr/local/mysql/bin</nowiki></code> to your path so you can always use mysql, mysqldump, mysqladmin and some others right from the shell.
 
You should add <code><nowiki>/usr/local/mysql/bin</nowiki></code> to your path so you can always use mysql, mysqldump, mysqladmin and some others right from the shell.
 
 
=== Starting Mysql at boot time ===
 
=== Starting Mysql at boot time ===
 
 
<pre><nowiki>
 
<pre><nowiki>
 
sudo cp support-files/mysql.server /etc/init.d/mysql
 
sudo cp support-files/mysql.server /etc/init.d/mysql
 
sudo chmod +x /etc/init.d/mysql
 
sudo chmod +x /etc/init.d/mysql
 
sudo update-rc.d mysql defaults
 
sudo update-rc.d mysql defaults
</nowiki></code>
+
</nowiki></pre>
 
+
 
When you restart mysql should be up if everything went ok.
 
When you restart mysql should be up if everything went ok.
 
 
 
=== MySQL Tools ===
 
=== 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:
 
* 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><nowiki>
 
<pre><nowiki>
 
mysql-admin
 
mysql-admin
</nowiki></code>
+
</nowiki></pre>
 
+
 
* 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:
 
* 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><nowiki>
 
<pre><nowiki>
 
phpmyadmin
 
phpmyadmin
</nowiki></code>
+
</nowiki></pre>
 
+
----
CategoryDocumentation CategoryCleanup
+
  
 
[[category:UbuntuHelp]]
 
[[category:UbuntuHelp]]

2008年10月19日 (日) 23:54的最新版本

Please do not make any edits to this article. Its contents are currently under review and being merged with the Ubuntu Server Guide. To find the Ubuntu Server Guide related to your specific version, please go to: https://help.ubuntu.com/ and click on Ubuntu Server Guide

While quite old, this content may still be useful while MySQL is still at version 5.

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/

You must install packages :

sudo apt-get install build-essential

You need development libraries

... but I'm not sure about which ones.

sudo apt-get install libncurses5 libncurses5-dev

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

You need to create the user and group

sudo groupadd mysql
sudo useradd -g mysql mysql

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! IconsPage?action=AttachFile&do=get&target=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)
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 
  • Pentium 4 (Intel)
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 
  • Generic
export CHOST="i686-pc-linux-gnu"
export CFLAGS="-mcpu=i686 -march=i686 -O3 -pipe -fomit-frame-pointer"
export CXX=gcc 

-fomit-frame-pointer 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.

./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

This will install mysql in /usr/local/mysql and data in /usr/local/mysql/data.

my.conf

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

sudo cp support-files/my-medium.cnf /etc/my.cnf

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.

sudo /usr/local/mysql/bin/mysql_install_db --user=mysql

Changing Owners

sudo chown -R root  /usr/local/mysql
sudo chown -R mysql /usr/local/mysql/var
sudo chgrp -R mysql /usr/local/mysql

Testing

Start the server

/usr/local/mysql/bin/mysqld_safe -user=mysql&

Set a root password for MySQL (does not affect system root's password)

/usr/local/mysql/bin/mysqladmin -u root password new_password

Try to log in!

/usr/local/mysql/bin/mysql

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

Starting Mysql at boot time

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

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:
mysql-admin
  • 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:
phpmyadmin