特殊:Badtitle/NS100:MYSQL5FromSource
文章出处: |
{{#if: | {{{2}}} | https://help.ubuntu.com/community/MYSQL5FromSource }} |
点击翻译: |
English {{#ifexist: {{#if: UbuntuHelp:MYSQL5FromSource | UbuntuHelp:MYSQL5FromSource | {{#if: | :}}MYSQL5FromSource}}/af | • {{#if: UbuntuHelp:MYSQL5FromSource|Afrikaans| [[::MYSQL5FromSource/af|Afrikaans]]}}|}} {{#ifexist: {{#if: UbuntuHelp:MYSQL5FromSource | UbuntuHelp:MYSQL5FromSource | {{#if: | :}}MYSQL5FromSource}}/ar | • {{#if: UbuntuHelp:MYSQL5FromSource|العربية| [[::MYSQL5FromSource/ar|العربية]]}}|}} {{#ifexist: {{#if: UbuntuHelp:MYSQL5FromSource | UbuntuHelp:MYSQL5FromSource | {{#if: | :}}MYSQL5FromSource}}/az | • {{#if: UbuntuHelp:MYSQL5FromSource|azərbaycanca| [[::MYSQL5FromSource/az|azərbaycanca]]}}|}} {{#ifexist: {{#if: UbuntuHelp:MYSQL5FromSource | UbuntuHelp:MYSQL5FromSource | {{#if: | :}}MYSQL5FromSource}}/bcc | • {{#if: UbuntuHelp:MYSQL5FromSource|جهلسری بلوچی| [[::MYSQL5FromSource/bcc|جهلسری بلوچی]]}}|}} {{#ifexist: {{#if: UbuntuHelp:MYSQL5FromSource | UbuntuHelp:MYSQL5FromSource | {{#if: | :}}MYSQL5FromSource}}/bg | • {{#if: UbuntuHelp:MYSQL5FromSource|български| [[::MYSQL5FromSource/bg|български]]}}|}} {{#ifexist: {{#if: UbuntuHelp:MYSQL5FromSource | UbuntuHelp:MYSQL5FromSource | {{#if: | :}}MYSQL5FromSource}}/br | • {{#if: UbuntuHelp:MYSQL5FromSource|brezhoneg| [[::MYSQL5FromSource/br|brezhoneg]]}}|}} {{#ifexist: {{#if: UbuntuHelp:MYSQL5FromSource | UbuntuHelp:MYSQL5FromSource | {{#if: | :}}MYSQL5FromSource}}/ca | • {{#if: UbuntuHelp:MYSQL5FromSource|català| [[::MYSQL5FromSource/ca|català]]}}|}} {{#ifexist: {{#if: UbuntuHelp:MYSQL5FromSource | UbuntuHelp:MYSQL5FromSource | {{#if: | :}}MYSQL5FromSource}}/cs | • {{#if: UbuntuHelp:MYSQL5FromSource|čeština| [[::MYSQL5FromSource/cs|čeština]]}}|}} {{#ifexist: {{#if: UbuntuHelp:MYSQL5FromSource | UbuntuHelp:MYSQL5FromSource | {{#if: | :}}MYSQL5FromSource}}/de | • {{#if: UbuntuHelp:MYSQL5FromSource|Deutsch| [[::MYSQL5FromSource/de|Deutsch]]}}|}} {{#ifexist: {{#if: UbuntuHelp:MYSQL5FromSource | UbuntuHelp:MYSQL5FromSource | {{#if: | :}}MYSQL5FromSource}}/el | • {{#if: UbuntuHelp:MYSQL5FromSource|Ελληνικά| [[::MYSQL5FromSource/el|Ελληνικά]]}}|}} {{#ifexist: {{#if: UbuntuHelp:MYSQL5FromSource | UbuntuHelp:MYSQL5FromSource | {{#if: | :}}MYSQL5FromSource}}/es | • {{#if: UbuntuHelp:MYSQL5FromSource|español| [[::MYSQL5FromSource/es|español]]}}|}} {{#ifexist: {{#if: UbuntuHelp:MYSQL5FromSource | UbuntuHelp:MYSQL5FromSource | {{#if: | :}}MYSQL5FromSource}}/fa | • {{#if: UbuntuHelp:MYSQL5FromSource|فارسی| [[::MYSQL5FromSource/fa|فارسی]]}}|}} {{#ifexist: {{#if: UbuntuHelp:MYSQL5FromSource | UbuntuHelp:MYSQL5FromSource | {{#if: | :}}MYSQL5FromSource}}/fi | • {{#if: UbuntuHelp:MYSQL5FromSource|suomi| [[::MYSQL5FromSource/fi|suomi]]}}|}} {{#ifexist: {{#if: UbuntuHelp:MYSQL5FromSource | UbuntuHelp:MYSQL5FromSource | {{#if: | :}}MYSQL5FromSource}}/fr | • {{#if: UbuntuHelp:MYSQL5FromSource|français| [[::MYSQL5FromSource/fr|français]]}}|}} {{#ifexist: {{#if: UbuntuHelp:MYSQL5FromSource | UbuntuHelp:MYSQL5FromSource | {{#if: | :}}MYSQL5FromSource}}/gu | • {{#if: UbuntuHelp:MYSQL5FromSource|ગુજરાતી| [[::MYSQL5FromSource/gu|ગુજરાતી]]}}|}} {{#ifexist: {{#if: UbuntuHelp:MYSQL5FromSource | UbuntuHelp:MYSQL5FromSource | {{#if: | :}}MYSQL5FromSource}}/he | • {{#if: UbuntuHelp:MYSQL5FromSource|עברית| [[::MYSQL5FromSource/he|עברית]]}}|}} {{#ifexist: {{#if: UbuntuHelp:MYSQL5FromSource | UbuntuHelp:MYSQL5FromSource | {{#if: | :}}MYSQL5FromSource}}/hu | • {{#if: UbuntuHelp:MYSQL5FromSource|magyar| [[::MYSQL5FromSource/hu|magyar]]}}|}} {{#ifexist: {{#if: UbuntuHelp:MYSQL5FromSource | UbuntuHelp:MYSQL5FromSource | {{#if: | :}}MYSQL5FromSource}}/id | • {{#if: UbuntuHelp:MYSQL5FromSource|Bahasa Indonesia| [[::MYSQL5FromSource/id|Bahasa Indonesia]]}}|}} {{#ifexist: {{#if: UbuntuHelp:MYSQL5FromSource | UbuntuHelp:MYSQL5FromSource | {{#if: | :}}MYSQL5FromSource}}/it | • {{#if: UbuntuHelp:MYSQL5FromSource|italiano| [[::MYSQL5FromSource/it|italiano]]}}|}} {{#ifexist: {{#if: UbuntuHelp:MYSQL5FromSource | UbuntuHelp:MYSQL5FromSource | {{#if: | :}}MYSQL5FromSource}}/ja | • {{#if: UbuntuHelp:MYSQL5FromSource|日本語| [[::MYSQL5FromSource/ja|日本語]]}}|}} {{#ifexist: {{#if: UbuntuHelp:MYSQL5FromSource | UbuntuHelp:MYSQL5FromSource | {{#if: | :}}MYSQL5FromSource}}/ko | • {{#if: UbuntuHelp:MYSQL5FromSource|한국어| [[::MYSQL5FromSource/ko|한국어]]}}|}} {{#ifexist: {{#if: UbuntuHelp:MYSQL5FromSource | UbuntuHelp:MYSQL5FromSource | {{#if: | :}}MYSQL5FromSource}}/ksh | • {{#if: UbuntuHelp:MYSQL5FromSource|Ripoarisch| [[::MYSQL5FromSource/ksh|Ripoarisch]]}}|}} {{#ifexist: {{#if: UbuntuHelp:MYSQL5FromSource | UbuntuHelp:MYSQL5FromSource | {{#if: | :}}MYSQL5FromSource}}/mr | • {{#if: UbuntuHelp:MYSQL5FromSource|मराठी| [[::MYSQL5FromSource/mr|मराठी]]}}|}} {{#ifexist: {{#if: UbuntuHelp:MYSQL5FromSource | UbuntuHelp:MYSQL5FromSource | {{#if: | :}}MYSQL5FromSource}}/ms | • {{#if: UbuntuHelp:MYSQL5FromSource|Bahasa Melayu| [[::MYSQL5FromSource/ms|Bahasa Melayu]]}}|}} {{#ifexist: {{#if: UbuntuHelp:MYSQL5FromSource | UbuntuHelp:MYSQL5FromSource | {{#if: | :}}MYSQL5FromSource}}/nl | • {{#if: UbuntuHelp:MYSQL5FromSource|Nederlands| [[::MYSQL5FromSource/nl|Nederlands]]}}|}} {{#ifexist: {{#if: UbuntuHelp:MYSQL5FromSource | UbuntuHelp:MYSQL5FromSource | {{#if: | :}}MYSQL5FromSource}}/no | • {{#if: UbuntuHelp:MYSQL5FromSource|norsk| [[::MYSQL5FromSource/no|norsk]]}}|}} {{#ifexist: {{#if: UbuntuHelp:MYSQL5FromSource | UbuntuHelp:MYSQL5FromSource | {{#if: | :}}MYSQL5FromSource}}/oc | • {{#if: UbuntuHelp:MYSQL5FromSource|occitan| [[::MYSQL5FromSource/oc|occitan]]}}|}} {{#ifexist: {{#if: UbuntuHelp:MYSQL5FromSource | UbuntuHelp:MYSQL5FromSource | {{#if: | :}}MYSQL5FromSource}}/pl | • {{#if: UbuntuHelp:MYSQL5FromSource|polski| [[::MYSQL5FromSource/pl|polski]]}}|}} {{#ifexist: {{#if: UbuntuHelp:MYSQL5FromSource | UbuntuHelp:MYSQL5FromSource | {{#if: | :}}MYSQL5FromSource}}/pt | • {{#if: UbuntuHelp:MYSQL5FromSource|português| [[::MYSQL5FromSource/pt|português]]}}|}} {{#ifexist: {{#if: UbuntuHelp:MYSQL5FromSource | UbuntuHelp:MYSQL5FromSource | {{#if: | :}}MYSQL5FromSource}}/ro | • {{#if: UbuntuHelp:MYSQL5FromSource|română| [[::MYSQL5FromSource/ro|română]]}}|}} {{#ifexist: {{#if: UbuntuHelp:MYSQL5FromSource | UbuntuHelp:MYSQL5FromSource | {{#if: | :}}MYSQL5FromSource}}/ru | • {{#if: UbuntuHelp:MYSQL5FromSource|русский| [[::MYSQL5FromSource/ru|русский]]}}|}} {{#ifexist: {{#if: UbuntuHelp:MYSQL5FromSource | UbuntuHelp:MYSQL5FromSource | {{#if: | :}}MYSQL5FromSource}}/si | • {{#if: UbuntuHelp:MYSQL5FromSource|සිංහල| [[::MYSQL5FromSource/si|සිංහල]]}}|}} {{#ifexist: {{#if: UbuntuHelp:MYSQL5FromSource | UbuntuHelp:MYSQL5FromSource | {{#if: | :}}MYSQL5FromSource}}/sq | • {{#if: UbuntuHelp:MYSQL5FromSource|shqip| [[::MYSQL5FromSource/sq|shqip]]}}|}} {{#ifexist: {{#if: UbuntuHelp:MYSQL5FromSource | UbuntuHelp:MYSQL5FromSource | {{#if: | :}}MYSQL5FromSource}}/sr | • {{#if: UbuntuHelp:MYSQL5FromSource|српски / srpski| [[::MYSQL5FromSource/sr|српски / srpski]]}}|}} {{#ifexist: {{#if: UbuntuHelp:MYSQL5FromSource | UbuntuHelp:MYSQL5FromSource | {{#if: | :}}MYSQL5FromSource}}/sv | • {{#if: UbuntuHelp:MYSQL5FromSource|svenska| [[::MYSQL5FromSource/sv|svenska]]}}|}} {{#ifexist: {{#if: UbuntuHelp:MYSQL5FromSource | UbuntuHelp:MYSQL5FromSource | {{#if: | :}}MYSQL5FromSource}}/th | • {{#if: UbuntuHelp:MYSQL5FromSource|ไทย| [[::MYSQL5FromSource/th|ไทย]]}}|}} {{#ifexist: {{#if: UbuntuHelp:MYSQL5FromSource | UbuntuHelp:MYSQL5FromSource | {{#if: | :}}MYSQL5FromSource}}/tr | • {{#if: UbuntuHelp:MYSQL5FromSource|Türkçe| [[::MYSQL5FromSource/tr|Türkçe]]}}|}} {{#ifexist: {{#if: UbuntuHelp:MYSQL5FromSource | UbuntuHelp:MYSQL5FromSource | {{#if: | :}}MYSQL5FromSource}}/vi | • {{#if: UbuntuHelp:MYSQL5FromSource|Tiếng Việt| [[::MYSQL5FromSource/vi|Tiếng Việt]]}}|}} {{#ifexist: {{#if: UbuntuHelp:MYSQL5FromSource | UbuntuHelp:MYSQL5FromSource | {{#if: | :}}MYSQL5FromSource}}/yue | • {{#if: UbuntuHelp:MYSQL5FromSource|粵語| [[::MYSQL5FromSource/yue|粵語]]}}|}} {{#ifexist: {{#if: UbuntuHelp:MYSQL5FromSource | UbuntuHelp:MYSQL5FromSource | {{#if: | :}}MYSQL5FromSource}}/zh | • {{#if: UbuntuHelp:MYSQL5FromSource|中文| [[::MYSQL5FromSource/zh|中文]]}}|}} {{#ifexist: {{#if: UbuntuHelp:MYSQL5FromSource | UbuntuHelp:MYSQL5FromSource | {{#if: | :}}MYSQL5FromSource}}/zh-hans | • {{#if: UbuntuHelp:MYSQL5FromSource|中文(简体)| [[::MYSQL5FromSource/zh-hans|中文(简体)]]}}|}} {{#ifexist: {{#if: UbuntuHelp:MYSQL5FromSource | UbuntuHelp:MYSQL5FromSource | {{#if: | :}}MYSQL5FromSource}}/zh-hant | • {{#if: UbuntuHelp:MYSQL5FromSource|中文(繁體)| [[::MYSQL5FromSource/zh-hant|中文(繁體)]]}}|}} |
{{#ifeq:UbuntuHelp:MYSQL5FromSource|:MYSQL5FromSource|请不要直接编辑翻译本页,本页将定期与来源同步。}} |
{{#ifexist: :MYSQL5FromSource/zh | | {{#ifexist: MYSQL5FromSource/zh | | {{#ifeq: {{#titleparts:MYSQL5FromSource|1|-1|}} | zh | | }} }} }} {{#ifeq: {{#titleparts:MYSQL5FromSource|1|-1|}} | zh | | }}
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! {{https://help.ubuntu.com/community/IconsPage?action=AttachFile&do=get&target=IconWarning3.png%7D%7D 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