linux 数据库

    xiaoxiao2021-03-25  112

    ###############mysql############## yum install mysql      mysql-server mysqladmin -uroot -predhat password westos           修改本地mysqlroot密码 mysqladmin -uroot -predhat -h 172.25.254.39 password westos  修改远程172.25.254.39mysql服务器 root密码     mysql_secure_installation                 第一次安装mysql以后通过这条命令可以对mysql进行设置 mysql -uroot -predhat                     从本机登录mysql数据库 show databases;                       显示数据库 use mysql;                        进入数据库 show tables;                          显示数据库中的表  desc user;                        查看user表的数据结构 flush privileges;                     刷新数据库信息 select host.user,password from user;             查询user表中的hostuserpassword字段 在数据库下输入命令 ,最好用大写。 create database westos;                       创建westos数据库

    use westos;   

                        create table linux(                       创建表,usernamepassword字段

    username varchar(15) not null, password varchar(15) not null

    );

    select * from mysql.user;                 查询mysql库下的user表中的所以

    alter table linux add age varchar(4);             添加age字段到linux表中

    ALTER TABLE linux DROP age                删除age字段

    ALTER TABLE linux ADD age VARCHAR(5)  AFTER name     name字段后添加字段age            show tables; desc linux; insert into linux values ('user1','passwd1');            linux表中插入值为username = user1password = password1

    update linux set password=password('passwd2') where username=user1;    更新linux表中user1 的密码为password2

    delete from linux where username=user1;                  删除linux表中user1的所以内容

    grant select on  *.* to user1@localhostidentified by 'passwd1'; 授权user1 密码为passwd1  并且只能在本地 查询数据库的所以内容

    grant all on mysql.* to user2@'%' identified by 'passwd2';       授权user2 密码为passwd2  可以从远程任意主机登录mysql 并且可以对mysql数据库任意操作 备份 /var/lib/mysql mysqldump -uroot -predhat mysql > mysql.bak   备份mysql库到mysql.bak mysql -uroot -predhat westos < mysql.bak  恢复mysql.bak westos mysql 密码恢复 /etc/init.d/mysqld stop mysqld_safe --skip-grant-tables &                 跳过grant-tables授权表  不需要认证登录本地mysql数据库 update mysql.user set password=password('westos') where user='root';    更新mysql.user 表中条件为root用户的密码为加密westos /etc/init.d/mysql restart phpmyadmin yum install php php-mysql httpd mysql mysql-server tar jxf phpmyadmin-*.tar.bz2 -C /var/www/html

    mv phpmyadmin phpadmin

    cp config.sample.inc.php config.inc.php

    vim config.inc.php

    add $cfg['blowfish_secret'] = 'test'; /etc/init.d/httpd start

    http://172.25.254.39/phpadmin

    转载请注明原文地址: https://ju.6miu.com/read-25385.html

    最新回复(0)