Linux_MariaDB installation

来源:互联网 发布:健身书籍知乎 编辑:程序博客网 时间:2024/06/13 00:34

via: http://my.oschina.net/myaniu/blog/145452

 

# tar zxvf  mariadb-5.5.31-linux-x86_64.tar.gz   

# mv mariadb-5.5.31-linux-x86_64 /usr/local/mysql 

# groupadd mysql                     增加 mysql 属组 

# useradd -g mysql mysql     增加 mysql 用户 并归于mysql 属组 

# chown mysql:mysql -Rf  /usr/local/mysql     设置 mysql 目录的用户及用户组归属。 

# chmod +x -Rf /usr/local/mysql    赐予可执行权限 

# cp /usr/local/mysql/support-files/my-medium.cnf /etc/my.cnf     复制默认mysql配置 文件到/etc 目录 

# /usr/local/mysql/scripts/mysql_install_db --user=mysql   初始化数据 库 (必须在mariadb的解压目录)

(若报错误

Installing MariaDB/MySQL system tables in './data' ...
./bin/mysqld: error while loading shared libraries: libaio.so.1: cannot open shared object file: No such file or directory

则 sudo apt-get install libaio1

)

(初始化成功后的建议信息如下:

To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system

PLEASE REMEMBER TO SET A PASSWORD FOR THE MariaDB root USER !
To do so, start the server, then issue the following commands:

'./bin/mysqladmin' -u root password 'new-password'
'./bin/mysqladmin' -u root -h F83Se password 'new-password'

Alternatively you can run:
'./bin/mysql_secure_installation'

which will also give you the option of removing the test
databases and anonymous user created by default.  This is
strongly recommended for production servers.

See the MariaDB Knowledgebase at http://mariadb.com/kb or the
MySQL manual for more instructions.

You can start the MariaDB daemon with:
cd '.' ; ./bin/mysqld_safe --datadir='./data'

You can test the MariaDB daemon with mysql-test-run.pl
cd './mysql-test' ; perl mysql-test-run.pl

Please report any problems at http://mariadb.org/jira

The latest information about MariaDB is available at http://mariadb.org/.
You can find additional information about the MySQL part at:
http://dev.mysql.com
Support MariaDB development by buying support/new features from
SkySQL Ab. You can contact us about this at sales@skysql.com.
Alternatively consider joining our community based development effort:
http://mariadb.com/kb/en/contributing-to-the-mariadb-project/
)

# cp  /usr/local/mysql/support-files/mysql.server    /etc/init.d/mysql   复制mysql服务程序 到系统 目录 

# chkconfig  mysql on   添加mysql 至系统服务并设置为开机启动 

# service  mysql  start  启动mysql

#vim /etc/profile   编辑profile,将mysql的可执行路径加入系统PATH

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

#source /etc/profile  使PATH生效。

#mysqladmin -u root password 'yourrootpassword' 设定root账号及密码

#mysql -uroot -p  使用root用户登录mysql

[none]>use mysql  切换至mysql数据库。

[mysql]>select user,host,password from user; --查看系统权限

[mysql]>drop user ''@'localhost'; --删除不安全的账户

[mysql]>drop user root@'::1';

[mysql]>drop user root@127.0.0.1;

...

[mysql]>select user,host,password from user; --再次查看系统权限,确保不安全的账户均被删除。

 

[mysql]>flush privileges;  --刷新权限

 

1)修改字符集为UTF8

#vi /etc/my.cnf

在[client]下面添加 default-character-set = utf8

在[mysqld]下面添加 character_set_server = utf8

修改完重启:#service  mysql  restart 

 

2)增加错误日志

#vi /etc/my.cnf

在[mysqld]下面添加:

log-error = /usr/local/mysql/log/error.log

general-log-file = /usr/local/mysql/log/mysql.log

修改完重启:#service  mysql  restart 

 

3) 设置为不区分大小写,linux下默认会区分大小写。

#vi /etc/my.cnf

在[mysqld]下面添加:

lower_case_table_name=1

修改完重启:#service  mysql  restart 

0 0
原创粉丝点击