mysql的安装以及开启远程访问

时间:2022-05-19 15:09:25

mysql安装   系统centos5.4

wget http://ftp.gnu.org/pub/gnu/ncurses/ncurses-5.6.tar.gz

tar zxvf ncurses-5.6.tar.gz

cd ncurses-5.6

./configure --prefix=/usr --with-shared --without-debug

make

make install clean


1.mysql的安装

    shell> groupadd mysql

    shell> useradd -s /sbin/nologin -M -g mysql mysql

    shell> tar -zxvf mysql

    shell> cd mysql-VERSION

./configure --prefix=/usr/local/mysql --enable-assembler --with-charset=gbk  --with-extra-charset=all --enable-thread-safe-client --with-big-tables --with-readline --with-ssl --with-embedded-server --enable-local-infile --with-plugins=innobase



make

make install

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

cp support-files/mysql.server /etc/init.d/mysqld

chmod +x /etc/init.d/mysqld

cd /usr/local/mysql

bin/mysql_install_db --user=mysql

chown -R root  .

chown -R mysql var

chgrp -R mysql .

/etc/init.d/mysqld start


#vi /etc/profile(内容如下)

PATH=$PATH:/usr/local/mysql/bin

# source /etc/profile



设置数据库密码


mysqladmin -u root password 123456 密码自己定这里只是个例子)

开启root 远程访问权限

mysql -p123456

mysql> grant all on *.* to root@'%' identified by '123456';

Query OK, 0 rows affected (0.00 sec)

mysql> flush privileges;

mysql> quit






mysqldump -uroot -ppassword --master-data --all-databases>mastersql2slave.sql (如果需要所有库使用)



create table data(name VARCHAR(20), address VARCHAR(50), phone VARCHAR(20));


insert into data(name,address,phone) values('ganlu','shenzhen','135000000');


>GRANT REPLICATION SLAVE,REPLICATION CLIENT,RELOAD,SUPER ON *.* TO ‘backup’@'192.168.0.40′ IDENTIFIED BY 'qawsed';



GRANT FILE ON *.* TO backup@'192.168.0.40' IDENTIFIED BY 'rsync.mysql';


本文出自 “ganlou0089.com” 博客,谢绝转载!