Install Mysql5.6 database in Ubuntu

Source: Internet
Author: User
Ubuntu install Mysql5.6 database 1) download: mysql-5.6.13-debian6.0-x86_64.debdev.mysql.comdownloadsmirror.php? Id41399) installation: $ sudodpkg-imysql-5.6.3-debian6.0-x86_64.debMysqlServer initialization in: optmysqlserver-5.63) configuration: $

Ubuntu install Mysql 5.6 database 1) download: mysql-5.6.13-debian6.0-x86_64.deb http://dev.mysql.com/downloads/mirror.php? Id = 413956 2) install: $ sudo dpkg-I mysql-5.6.3-debian6.0-x86_64.deb Mysql Server initialized at:/opt/mysql/server-5.6 3) Configure: $

Ubuntu install Mysql 5.6 database 1) download: mysql-5.6.13-debian6.0-x86_64.deb

Http://dev.mysql.com/downloads/mirror.php? Id = 413956

2) installation:

$ sudo dpkg -i mysql-5.6.3-debian6.0-x86_64.deb

The Mysql Server is initialized at:/opt/mysql/server-5.6.

3) Configuration:

$ Sudo groupadd mysql $ sudo useradd-r-g mysql $ sudo apt-get install libaio-dev # I don't know how to use this $ sudo ln-s/opt/mysql/server- 5.6/usr/local/mysql $ sudo mkdir/usr/local/mysql/data $ sudo chown-R mysql. /usr/local/mysql/data
# Initialize the database $ sudo/usr/local/mysql/scripts/mysql_install_db -- user = mysql -- basedir =/usr/local/mysql -- datadir =/usr/local/mysql/data # put the startup shell of mysqld in the system service directory: $ sudo cp/usr/local/mysql/support-files/mysql. server/etc/init. d/mysql # Put the mysql configuration file under the System Configuration/etc/. mysql uses this configuration file globally: $ sudo cp/usr/local/mysql/support-files/my-default.cnf/etc/my. cnf

4) start/stop Mysql

$ sudo /etc/init.d/mysql start$ sudo /etc/init.d/mysql stop


5) change the mysql root administrator password to abc. We strongly recommend that you develop the Machine Password: root

$ sudo /usr/local/mysql/bin/mysqladmin -u root password abc

6) log on to mysql (after startup)

$ Sudo/usr/local/mysql/bin/mysql-u root-p
 <数据库名>
  
# Or $ sudo/usr/local/mysql/bin/mysql-u root-p # display database> show databases; # use Database> use Database Name;> show all tables> show tables; # redirect output to File> tee/home/sqlc.txt # windows:> tee "c: /temp/sqlc.txt "# the subsequent SQL statement output is redirected to the file: sqlc.txt> show create table mytest;> select * from mytest; # exit mysql Console> exit; # remotely log on to mysql. username: root, password: 123456 Remote Server ip: 192.168.1.88 service protocol port: 3306 remote database name: testdb $ mysql-u root-p123456-h 192.168.1.88-P 3306-D testdb
 

The following program is executed on windows:

C: \ Program Files \ MySQL Server 5.5 \ bin \ mysql.exe

Reference:

Http://www.360doc.com/content/12/0919/18/8006573_237073873.shtml

7) timestamp usage of mysql

For Mysql tables, if you need to create time for each record and the time when any field is updated at the same time, you can follow the method below:

mysql>CREATETABLE mytest (        name VARCHAR(100),        create_time DATETIME,        update_time TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATECURRENT_TIMESTAMP)


Then create a trigger:

delimiter|CREATETRIGGER default_datetime BEFORE INSERT ON test6        for each row                  if new.create_time is null then                           set new.create_time = now();                  end if; |delimiter;

In this way, when a new record is inserted, create_time and update_time will automatically record the current time. Any update will cause the update_time to be automatically updated.


8) enable remote connection on the mysql server

Assume that my Mysql server is installed on machine A. When I remotely connect to Mysql on another machine B or machine A, the remote connection fails. By default, remote connection is not allowed for Mysql installation. Therefore, you must enable remote connection.

# On Machine A, use Mysql to locally connect to Mysql: $/usr/local/mysql/bin/mysql-u root-pmysql> grant all privileges on *. * to 'root' @ '%' identified by 'root123' with grant option; mysql> flush privileges; mysql> exit; # Install the mysql client on a remote client machine, and connect to the Service $ sudo apt-get install mysql-client-core-5.5 $ mysql-u root-P 3306-h 192.168.92.117-proot123

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.