Vous êtes sur la page 1sur 3

MySQL 5.

5 work sheet
1. Installation: 1) Add a user and a group named mysql # groupadd mysql # useradd -g mysql mysql

2) Extract and install the downloaded source code (I stored a file mysql-5.5.25.tar.gz under the directory /usr/local/src/.) # cd /usr/local/src/ # tar xvfz mysql-5.5.25.tar.gz # cd mysql-5.5.25 # cmake -DCMAKE_INSTALL_PREFIX=/usr/local/server/mysql \ // install directory -DWITH_EXTRA_CHARSETS=all \ -DMYSQL_DATADIR=/Your_Target_Data_PATH/test_data \ // data directory -DENABLED_LOCAL_INFILE=1 \ -DWITH_INNOBASE_STORAGE_ENGINE=1 \ -DMYSQL_UNIX_ADDR=/tmp/mysql.sock \ -DSYSCONFDIR=/etc \ -DDEFAULT_CHARSET=utf8 \ // basic language set -DDEFAULT_COLLATION=utf8_general_ci \ -DWITH_EXTRA_CHARSETS=all \ -DMYSQL_TCP_PORT=3306 // port number # make && make install

3) Post-installation setup # cp support-files/my-huge.cnf /etc/my.cnf <--- copying mysql configuration file to /etc/ # cp support-files/mysql.server /etc/init.d/mysqld <--- copying mysql daemon to /etc/init.d/ # vi /etc/init.d/mysqld -------------------------------------datadir=/Your_Target_Data_PATH/test_data <--- specifying and storing DB directory --------------------------------------# chmod 755 /etc/init.d/mysqld <---add the executable permission on mysql daemon # chown -R mysql:mysql /usr/local/server/mysql # /usr/local/server/mysql/scripts/mysql_install_db user=mysql \d

--basedir=/usr/local/server/mysql \ --datadir=/usr/local/server/mysql/data <---create DB # /etc/init.d/mysqld start <--- starting mysql (== /usr/local/server/mysql/bin/mysqld_safe &) # chkconfig --add mysqld # /usr/local/server/mysql/bin/mysqladmin -u root password YOUR_PWD <--- set mysql root pwd # ln -s /usr/local/server/mysql/bin/mysql /usr/bin/ <---symbolic link # ln -s /usr/local/server/mysql/bin/mysqldump /usr/bin/

4) Connecting to mysql # mysql -u root -p <---connecting to mysql as an user called root. Password will be asked from tty
Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 2 Server version: 5.5.25-log Source distribution Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql>

mysql> \h For information about MySQL products and services, visit: http://www.mysql.com/ For developer information, including the MySQL Reference Manual, visit: http://dev.mysql.com/ List of all MySQL commands: Note that all text commands must be first on line and end with ';' ? clear (\?) Synonym for `help'. (\c) Clear the current input statement.

connect (\r) Reconnect to the server. Optional arguments are db and host. delimiter (\d) Set statement delimiter. edit ego exit go help notee pager print quit rehash status system tee use (\e) Edit command with $EDITOR. (\G) Send command to mysql server, display result vertically. (\q) Exit mysql. Same as quit. (\g) Send command to mysql server. (\h) Display this help. (\t) Don't write into outfile. (\P) Set PAGER [to_pager]. Print the query results via PAGER. (\p) Print current command. (\q) Quit mysql. (\#) Rebuild completion hash. (\s) Get status information from the server. (\!) Execute a system shell command. (\T) Set outfile [to_outfile]. Append everything into given outfile. (\u) Use another database. Takes database name as argument.

nopager (\n) Disable pager, print to stdout.

prompt (\R) Change your mysql prompt.

source (\.) Execute an SQL script file. Takes a file name as an argument.

charset (\C) Switch to another charset. Might be needed for processing binlog with multi-byte charsets. warnings (\W) Show warnings after every statement. nowarning (\w) Don't show warnings after every statement. For server side help, type 'help contents'

Vous aimerez peut-être aussi