zoukankan      html  css  js  c++  java
  • Centos 6.5 RedHat 6 安装mysql

    所需文件列表, 这些文件在安装光盘内的Packages文件夹内, 也可以到MySQL官方网站下载其他版本(需要FQ). 将这些文件放在/usr/loca/src文件夹:

    mysql-5.1.71-1.el6.x86_64.rpm  mysql-devel-5.1.71-1.el6.x86_64.rpm  mysql-libs-5.1.71-1.el6.x86_64.rpm

    安装:

    cd /usr/local/src
    yum localinstall *.rpm -y

    启动服务:

    service mysqld start

    启动MySQL:

    mysql -uroot

    相关命令:

    1、登陆MySQL:
    mysql -u root -p
    password:输入密码
    2、查看用户信息
    select user,host,password from mysql.user;
    select user,host from mysql.user;
    3、设置密码
    set password for root@localhost=password('在这里填入root密码');
    4、修改密码
    方法1:mysqladmin -u root -p password newpassword
    方法2: #mysql -u root -p mysql
    mysql>UPDATE user SET password=PASSWORD("new") WHERE user='root';
    mysql>flush privileges;
    5、删除匿名用户
    delete from mysql.user where user='';
    6、查看系统已存在的数据库
    show databases;
    7、删除名为test的空数据库
    drop database test;
    8、建立mysql用户
    例a:建立对test数据库有完全操作权限的名为centospub的用户
    mysql>grant all privileges on test.* to centospub@localhost identified by 'password';
    例b:增加一个用户test1密码为abc,让他可以在任何主机上登录,并对所有数据库有查询、插入、修改、删除的权限。首先用以root用户连入MYSQL,然后键入以下命令:
    mysql>grant select,insert,update,delete on *.* to test1@"%" Identified by "abc";
    但例b增加的用户是十分危险的,你想如某个人知道test1的密码,那么他就可以在internet上的任何一台电脑上登录你的mysql数据库并对你的数据可以为所欲为了。
    例c:增加一个用户test2密码为abc,让他只可以在localhost上登录,并可以对数据库mydb进行查询、插入、修改、删除的操作(localhost指本地主机,即MYSQL数据库所在的那台主机),这样用户即使用知道test2的密码,他也无法从internet上直接访问数据库,只能通过MYSQL主机上的web页来访问了。
    mysql>grant select,insert,update,delete on mydb.* to test2@localhost identified by "abc";
    9、查找确认centospub用户的存在与否
    select user from mysql.user where user='centospub';
    10、 建立名为test的数据库
    create database test;
    11、取消centospub用户对数据库的操作权限
    revoke all privileges on *.* from centospub@localhost;
    12、删除centospub用户
    delete from mysql.user where user='centospub' and host='localhost';
    13、刷新,使所做的改动生效
    flush privileges;
    14、忘记MySQL的root密码,怎么修改


    如果 MySQL 正在运行,首先杀之: killall -TERM mysqld。
    启动 MySQL :PATH_TO_MYSQL/bin/mysqld --skip-grant-tables &
    就可以不需要密码就进入 MySQL 了。
    然后就是
    mysql>use mysql
    mysql>update user set password=password("new_pass") where user="root";
    mysql>flush privileges;
    重新杀 MySQL ,用正常方法启动 MySQL
    一定注意:很多新手没有用password=password("..."),而是直接password="..."所以改掉密码不好使

    create database mysql_mr default character set utf8;


    一、关闭相关应用
    二、停止mysql
    bin/mysqladmin -u root -p shutdown
    三、备份my.cnf
    cd /etc
    cp my.cnf my.cnf_bak
    四、修改my.cnf
    [mysqld] 后加入
    vi my.cnf
    default-storage-engine=InnoDB

    五、删除/mysql/data目录下的ib_logfile0,ib_logfile1
    否则在启动mysql时会遇到下述错误:
    [ERROR] Plugin 'InnoDB' init function returned error.
    [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
    [ERROR] Unknown/unsupported table type: InnoDB
    [ERROR] Aborting
    六、启动mysql
    cd /home/administrator/mysql
    bin/mysqld_safe -user=root &
    七、登录mysql检查修改是否成功
    mysql -h ip -u root -p
    mysql>show engines;
    mysql>show variables like'storage_engine';
    +----------------+--------+
    | Variable_name | Value |
    +----------------+--------+
    | storage_engine | InnoDB |
    +----------------+--------+

    --------------------------------------------------------------------------------------------------

    有时候,我们因为工作的需要会重新配置MySQL数据库引擎innodb。那么如何在Linux系统下重新配置MySQL数据库引擎innodb呢?本文我们就来介绍这一部分内容,接下来就让我们来一起了解一下吧!

    1)停止mysql服务。

    [root@mysql ~]# service mysqld stop。

    2)修改mysql的配置文件。

    [root@mysql ~]# vi /etc/my.cnf。

    3)删除datedir文件夹下的包含ib_logfile1和ibdata的文件。

    4)在根目录下建立mysqldata文件夹。

    5)启动使设置生效。

    my.cnf修改内容如下:


    [mysqld]


    datadir=/var/lib/mysql


    socket=/var/lib/mysql/mysql.sock


    user=mysql


    # Default to using old password format for compatibility with mysql 3.x


    # clients (those using the mysqlclient10 compatibility package).


    old_passwords=1 # Disabling symbolic-links is recommended to prevent assorted security risks;


    # to do so, uncomment this line:


    # symbolic-links=0 default-storage-engine=InnoDB


    set-variable= transaction-isolation=READ-COMMITTED innodb_data_home_dir =


    innodb_data_file_path =/mysqldata/ibdata1:2000M;/mysqldata/ibdata2:2000M:autoextend innodb_buffer_pool_size=1G


    innodb_additional_mem_pool_size=20M


    innodb_log_file_size=256M


    innodb_log_buffer_size=8M


    innodb_flush_log_at_trx_commit=1


    innodb_lock_wait_timeout=50


    innodb_thread_concurrency=5 [mysqld_safe]


    log-error=/var/log/mysqld.log


    pid-file=/var/run/mysqld/mysqld.pid

    --------------------------------------------------------------------------------------------------
    linux下安装mysql及用户、引擎、连接数、编码等相关设置

    Mysql版本:5.1.41
    安装过程:

    1. 安装Server:
    # rpm -ivh MySQL-server-community-5.1.41-0.rhel5.i386.rpm
    安装后路径
    数据库目录:/var/lib/mysql/
    配置文件:/usr/share/mysql
    相关命令:/usr/bin
    启动脚本:/etc/rc.d/init.d/

    2. 安装Client:
    # rpm -ivh MySQL-client-community-5.1.41-0.rhel5.i386.rpm

    3. 默认会添加自启动程序并启动Mysql,查看Mysql是否已经启动。
    # netstat -nat

    4. 修改root账号密码。
    mysql>update mysql.user set password=PASSWORD('newpassword') where User='root';

    5. 增加root账号远程访问权限
    mysql>grant all on *.* to " Identified by "root123456";

    6. 增加非root用户,用户远程访问。
    mysql>grant select,insert,update,delete on mydata.* to test" Identified by "test123456";

    7. 修改my.cnf配置文件,修改mysql编码为gbk
    # cp /usr/share/mysql/my-medium.cnf /etc/my.cnf
    # vi /etc/my.cnf
    修改下面的内容:
    [client]
    default-character-set=gbk
    [mysqld]
    default-character-set=gbk
    [mysql.server]
    default-character-set=gbk
    [mysqld_safe]
    default-character-set=gbk
    [mysql]
    default-character-set=gbk

    8. 修改my.cnf配置文件,设置默认引擎为InnoDB,在[mysqld]下面最后增加下面两句。
    default-storage-engine = InnoDB
    default_table_type = InnoDB

    同时打开下面的内容:
    innodb_data_home_dir = /var/lib/mysql/
    innodb_data_file_path = ibdata1:10M:autoextend
    innodb_log_group_home_dir = /var/lib/mysql/
    # You can set .._buffer_pool_size up to 50 - 80 %
    # of RAM but beware of setting memory usage too high
    innodb_buffer_pool_size = 16M
    innodb_additional_mem_pool_size = 2M
    # Set .._log_file_size to 25 % of buffer pool size
    innodb_log_file_size = 5M
    innodb_log_buffer_size = 8M
    innodb_flush_log_at_trx_commit = 1
    innodb_lock_wait_timeout = 50

    9. 修改最大连接数,默认是151 ,修改为500
    #vi /etc/my.conf
    [mysqld]
    max_connections=500

    10. 重启mysql
    #service mysql restart

    11. 查看设置是否生效。
    mysql> show variables like 'character/_set/_%';
    mysql> show variables like 'max_con_%';

    12. 相关命令
    mysql> show databases;
    mysql> use datebase;
    mysql> show tables;
    mysql> desc table_name;
    mysql> create database db;
    mysql> drop database db;
    mysql> create table table_name...;
    mysql> drop table table_name;
    mysql> insert into name values...;
    mysql> update name set...;
    mysql> delete from name where...;
    mysql> alter table survyssrs MODIFY supportAvaiScore varchar(10)...;
    mysql> update name set...;
    mysql> mysqldump -u root -p db > db_20091125.sql(备份数据库)
    mysql> mysql -u root -p db < db_20091125.sql(还原数据库)
    mysql> mysqldump -u root -p -h 192.168.1.105 db table >/home/table.sql(备份表)
    mysql> mysql -u root -p db < table.sql(还原表)

    13. 忘记root密码的操作。
    a. 关闭mysql
    b. /usr/bin/mysqld_safe --skip-grant-tables &
    c. update mysql.user set password=PASSWORD('newpassword') where User='root';

  • 相关阅读:
    奇数阶魔方问题
    《DSP using MATLAB》示例9.3
    《DSP using MATLAB》示例9.2
    《DSP using MATLAB》示例9.1
    找个目标很重要
    《DSP using MATLAB》示例Example 8.30
    《DSP using MATLAB》示例Example 8.29
    《DSP using MATLAB》示例Example 8.28
    《DSP using MATLAB》示例Example 8.27
    《DSP using MATLAB》示例Example 8.26
  • 原文地址:https://www.cnblogs.com/inthedark/p/4631210.html
Copyright © 2011-2022 走看看