设置“D:\S1DB”数据库创建目录,添加名为“S1EPDB”自动运行的Windows服务并设置root用户密码为“devuser”。
4.启动服务
cmd:
sc start S1EPDBService
5.登录
cmd:
mysql -u root -P
6.建立数据库s1epdb
cmd:
create database s1epdb default charset utf8 COLLATE utf8_general_ci;
7.备份与还原
备份:
mysqldump --add-drop-table -R -uroot -pdevuser s1epdb> backupfile.sql
如果你以系统服务方式运行数据库实例,可以在命令行中执行以下命令以完全移除:
sc stop S1EPDBService
sc delete S1EPDBService
rmdir /s /q D:\S1DB
5.配置.cnf文件
On Windows, my.ini
can be used as well as my.cnf
, and MariaDB looks in the following locations.
Location | Scope |
---|---|
%PROGRAMDATA%\MySQL\MySQL Server x.x\my.cnf | Global (x.x refers to the version) |
%WINDIR%\my.cnf | Global |
C:\my.cnf | Global |
INSTALLDIR\my.cnf | Global |
defaults-extra-file | File specified with --defaults-extra-file=path, if any |
配置文件就是不用输入很多的--option,比如
mysql_config_editor — MySQL Configuration Utility
创建mariadb account,
首先必须登录的user要有create user权限,查看登录的user有哪些权限可以用
show grants for 'root'@locahost;
+---------------------------------------------------------------------+ | Grants for root@localhost | +---------------------------------------------------------------------+ | GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' WITH GRANT OPTION | +---------------------------------------------------------------------+
my_print_defaults mysqldump 列出mysqldump 的
修改其中的任何一个,会按顺序覆盖,我把D:\software\mariadb-10.1.19-winx64 \ 下的my-large.ini copy一个重命名称my.cnf
查询用户权限:
(1)查询所有用户:
SELECT DISTINCT CONCAT('User: ''',user,'''@''',host,''';') AS query FROM MySQL.user;
(2)查看数据库中具体某个用户的权限:
方法一: show grants for 'username'@'%';
方法二: select * from mysql.user where user='aabb'(但是无法看到具体对应的表的权限)
问题重现(以下讨论范围仅限Windows环境):
C:\AppServ\MySQL> mysql -u root -p
Enter password:
ERROR 1045 (28000): Access denied for user'root'@'localhost'(using password: YES)
编辑mysql配置文件my.ini(不知道在哪请搜索),在[mysqld]这个条目下加入
保存退出后重启mysql
1.点击“开始”->“运行”(快捷键Win+R)。
2.启动:输入 net stop mysql
3.停止:输入 net start mysql
这时候在cmd里面输入mysql -u root -p就可以不用密码登录了,出现password:的时候直接回车可以进入,不会出现ERROR 1045 (28000),但很多操作都会受限制,因为我们不能grant(没有权限)。按下面的流程走(红色部分为输入部分,粉红色的是执行后显示的代码不用输入):
1.进入mysql数据库:(用户是mysql的user)
mysql> use mysql;
Database changed
2.给root用户设置新密码,蓝色部分自己输入:
mysql> update user set password=password("新密码") where user="root";
Query OK,
Rows matched:
3.刷新数据库
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
4.退出mysql:
mysql> quit
Bye
改好之后,再修改一下my.ini这个文件,把我们刚才加入的"skip-grant-tables"这行删除,保存退出再重启mysql就可以了。
远程连不上数据库,是由于需要配置权限。
1、myisam和innodb是mysql的两种不同的执行引擎
2、myisam追求的效率,不支持事务处理;而innodb则支持。