- 论坛徽章:
- 0
|
1. groupadd mysql
2. mkdir /home/mysql
3. useradd -g mysql -d /home/mysql mysql 4: sudo mkdir /usr/local/mysql
5:cd /usr/local/mysql 6:chown -R mysql . 7:chgrp -R mysql . 8:cd /home/mysql #此处假设源代码在/home/mysql下。
9: sudo ./configure --prefix=/usr/local/mysql #安装到/usr/local/mysql下。
10:sudo make
11: sudo make install
12:cd /usr/local/mysql
./scripts/mysql_install_db --user=mysql (一定要在mysql目录下执行,注意输出的文字,里边有修改root密码和启动mysql的命令) 为root设置密码: ./bin/mysqladmin -u root password 'passw0rd'
配置和管理msyql:1. 修改mysql最大连接数:cp support-files/my-medium.cnf ./my.cnf,vim my.cnf,增加或修改max_connections=1024
关于my.cnf:mysql按照下列顺序搜索my.cnf:/etc,mysql安装目录,安装目录下的data。/etc下的是全局设置。
2. 启动mysql:/usr/local/mysql/bin/mysqld_safe --user=mysql &
3. 停止mysql:mysqladmin -uroot -ppassw0rd shutdown 注意,u,p后没有空格
4. 设置mysql自启动:把启动命令加入/etc/rc.local文件中
5. 允许root远程登陆:
1)本机登陆mysql:mysql -u root -p (-p一定要有);改变数据库:use mysql;
2)从所有主机:grant all privileges on *.* to root@"%" identified by "passw0rd" with grant option;
3)从指定主机:grant all privileges on *.* to root@"192.168.11.205" identified by "passw0rd" with grant option; flush privileges;
4) 进mysql库查看host为%的数据是否添加:use mysql; select * from user;
6. 创建数据库,创建user:
1) 建库:create database test1;
2) 建用户,赋权:grant all privileges on test1.* to user_test@"%" identified by "passw0rd" with grant option;
3)删除数据库:drop database test1;
7. 删除权限:
1) revoke all privileges on test1.* from test1@"%";
2) use mysql;
3) delete from user where user="root" and host="%";
4) flush privileges;
8. 显示所有的数据库:show databases; 显示库中所有的表:show tables;
9. 远程登录mysql:mysql -h ip -u user -p
10. 设置字符集(以utf8为例):
1) 查看当前的编码:show variables like 'character%';
2) 修改my.cnf,在[client]下添加default-character-set=utf8
3) 在[server]下添加default-character-set=utf8,init_connect='SET NAMES utf8;'
4) 重启mysql。
注:只有修改/etc下的my.cnf才能使client的设置起效,安装目录下的设置只能使server的设置有效。
问题解决:UBUNTU下编译出现No curses/termcap library found的错误sudo apt-get install libncurses5-dev
本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u3/111049/showart_2158969.html |
|