Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 

Link

  • To stop the mysql process on mac OS
$ sudo launchctl unload -w /Library/LaunchDaemons/com.oracle.oss.mysql.mysqld.plist
/Library/LaunchDaemons/com.oracle.oss.mysql.mysqld.plist: Operation now in progress
  • Create persistent directory
$ mkdir /Users/[your_username]/Develop
$ mkdir /Users/[your_username]/Develop/mysql_data
$ mkdir /Users/[your_username]/Develop/mysql_data/8.0
  • Create docker network
$ docker network create dev-network
  • Starting the docker container on local
$ docker run --restart always --name mysql8.0 --net dev-network -v /Users/ankitsinghrathi/Develop/mysql_data/8.0:/var/lib/mysql -p 3306:3306 -d -e MYSQL_ROOT_PASSWORD=password mysql:8.0
  • Connecting to mysql
$ mysql -h127.0.0.1 -uroot -ppassword                   
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 10
Server version: 8.0.23 MySQL Community Server - GPL

Copyright (c) 2000, 2021, Oracle and/or its affiliates.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> 
  • Connecting to mysql using python
$ pip3 install mysql-connector-python
import mysql.connector
mydb = mysql.connector.connect(
    host="localhost",
    user="root",
    password="password"
)
mycursor = mydb.cursor()
mycursor.execute("CREATE DATABASE mydatabase")
mycursor.execute("show databases")
for x in mycursor:
    print(x)
...
('information_schema',)
('mydatabase',)
('mysql',)
('performance_schema',)
('sys',)